mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into convert-to-named-parameters
This commit is contained in:
commit
9270e58eaf
233 files changed
+74912
-1966
No files matched your search
@@ -16,7 +16,7 @@ Please fill in the *entire* template below.
|
||||
-->
|
||||
|
||||
<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
|
||||
**TypeScript Version:** 3.3.0-dev.201xxxxx
|
||||
**TypeScript Version:** 3.4.0-dev.201xxxxx
|
||||
|
||||
<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
|
||||
**Search Terms:**
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ task("watch-tsserver").flags = {
|
||||
" --built": "Compile using the built version of the compiler."
|
||||
}
|
||||
|
||||
task("min", series(lkgPreBuild, buildTsc, buildServer));
|
||||
task("min", series(lkgPreBuild, parallel(buildTsc, buildServer)));
|
||||
task("min").description = "Builds only tsc and tsserver";
|
||||
task("min").flags = {
|
||||
" --built": "Compile using the built version of the compiler."
|
||||
|
||||
+1
-1
@@ -3715,7 +3715,7 @@ the array literal initializer expression is contextually typed by the implied ty
|
||||
|
||||
## <a name="5.3"/>5.3 Let and Const Declarations
|
||||
|
||||
Let and const declarations are exended to include optional type annotations.
|
||||
Let and const declarations are extended to include optional type annotations.
|
||||
|
||||
  *LexicalBinding:* *( Modified )*
|
||||
   *SimpleLexicalBinding*
|
||||
|
||||
Vendored
+2
-2
@@ -1046,14 +1046,14 @@ interface JSON {
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@ import child_process = require("child_process");
|
||||
|
||||
type Author = {
|
||||
displayNames: string[];
|
||||
preferedName?: string;
|
||||
preferredName?: string;
|
||||
emails: string[];
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ const authorsPath = path.resolve("../AUTHORS.md");
|
||||
|
||||
function getKnownAuthors(): Author[] {
|
||||
const segmentRegExp = /\s?([^<]+)\s+<([^>]+)>/g;
|
||||
const preferedNameRegeExp = /\s?#\s?([^#]+)$/;
|
||||
const preferredNameRegeExp = /\s?#\s?([^#]+)$/;
|
||||
const knownAuthors: Author[] = [];
|
||||
|
||||
if (!fs.existsSync(mailMapPath)) {
|
||||
@@ -37,13 +37,13 @@ function getKnownAuthors(): Author[] {
|
||||
author.displayNames.push(match[1]);
|
||||
author.emails.push(match[2]);
|
||||
}
|
||||
if (match = preferedNameRegeExp.exec(line)) {
|
||||
author.preferedName = match[1];
|
||||
if (match = preferredNameRegeExp.exec(line)) {
|
||||
author.preferredName = match[1];
|
||||
}
|
||||
if (!author.emails) continue;
|
||||
knownAuthors.push(author);
|
||||
if (line.indexOf("#") > 0 && !author.preferedName) {
|
||||
throw new Error("Could not match prefered name for: " + line);
|
||||
if (line.indexOf("#") > 0 && !author.preferredName) {
|
||||
throw new Error("Could not match preferred name for: " + line);
|
||||
}
|
||||
// console.log("===> line: " + line);
|
||||
// console.log(JSON.stringify(author, undefined, 2));
|
||||
@@ -52,7 +52,7 @@ function getKnownAuthors(): Author[] {
|
||||
}
|
||||
|
||||
function getAuthorName(author: Author) {
|
||||
return author.preferedName || author.displayNames[0];
|
||||
return author.preferredName || author.displayNames[0];
|
||||
}
|
||||
|
||||
function getKnownAuthorMaps() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import cp = require('child_process');
|
||||
import fs = require('fs');
|
||||
|
||||
// Slice off 'node bisect-test.js' from the commandline args
|
||||
// Slice off 'node bisect-test.js' from the command line args
|
||||
var args = process.argv.slice(2);
|
||||
|
||||
function tsc(tscArgs: string, onExit: (exitCode: number) => void) {
|
||||
|
||||
@@ -30,7 +30,7 @@ var rawCompilerSources = "";
|
||||
sourceFiles.forEach(f=> {
|
||||
rawCompilerSources += "\r\n" + fs.readFileSync(path.join(tsSourceDir, f)).toString();
|
||||
});
|
||||
var compilerSoruces = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`;
|
||||
var compilerSources = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`;
|
||||
|
||||
// .js code for the compiler, what we are actually testing
|
||||
var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString();
|
||||
@@ -38,7 +38,7 @@ rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.
|
||||
|
||||
// lib.d.ts sources
|
||||
var rawLibSources = fs.readFileSync(path.join(tsBuildDir, "lib.d.ts")).toString();
|
||||
var libSoruces = `var libSources = ${JSON.stringify(rawLibSources) };`;
|
||||
var libSources = `var libSources = ${JSON.stringify(rawLibSources) };`;
|
||||
|
||||
// write test output
|
||||
if (!fs.existsSync(testOutputDir)) {
|
||||
@@ -48,7 +48,7 @@ if (!fs.existsSync(testOutputDir)) {
|
||||
// 1. compiler ts sources, used to test
|
||||
fs.writeFileSync(
|
||||
path.join(testOutputDir, "compilerSources.js"),
|
||||
`${ compilerSoruces } \r\n ${ libSoruces }`);
|
||||
`${ compilerSources } \r\n ${ libSources }`);
|
||||
|
||||
// 2. the compiler js sources + a call the compiler
|
||||
fs.writeFileSync(
|
||||
|
||||
@@ -1,177 +1,177 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as xml2js from "xml2js";
|
||||
|
||||
function main(): void {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length !== 3) {
|
||||
console.log("Usage:");
|
||||
console.log("\tnode generateLocalizedDiagnosticMessages.js <lcl source directory> <output directory> <generated diagnostics map file>");
|
||||
return;
|
||||
}
|
||||
|
||||
const inputPath = args[0];
|
||||
const outputPath = args[1];
|
||||
const diagnosticsMapFilePath = args[2];
|
||||
|
||||
// generate the lcg file for enu
|
||||
generateLCGFile();
|
||||
|
||||
// generate other langs
|
||||
fs.readdir(inputPath, (err, files) => {
|
||||
handleError(err);
|
||||
files.forEach(visitDirectory);
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
function visitDirectory(name: string) {
|
||||
const inputFilePath = path.join(inputPath, name, "diagnosticMessages", "diagnosticMessages.generated.json.lcl");
|
||||
|
||||
fs.readFile(inputFilePath, (err, data) => {
|
||||
handleError(err);
|
||||
xml2js.parseString(data.toString(), (err, result) => {
|
||||
handleError(err);
|
||||
if (!result || !result.LCX || !result.LCX.$ || !result.LCX.$.TgtCul) {
|
||||
console.error("Unexpected XML file structure. Expected to find result.LCX.$.TgtCul.");
|
||||
process.exit(1);
|
||||
}
|
||||
const outputDirectoryName = getPreferedLocaleName(result.LCX.$.TgtCul).toLowerCase();
|
||||
if (!outputDirectoryName) {
|
||||
console.error(`Invalid output locale name for '${result.LCX.$.TgtCul}'.`);
|
||||
process.exit(1);
|
||||
}
|
||||
writeFile(path.join(outputPath, outputDirectoryName, "diagnosticMessages.generated.json"), xmlObjectToString(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A locale name is based on the language tagging conventions of RFC 4646 (Windows Vista
|
||||
* and later), and is represented by LOCALE_SNAME.
|
||||
* Generally, the pattern <language>-<REGION> is used. Here, language is a lowercase ISO 639
|
||||
* language code. The codes from ISO 639-1 are used when available. Otherwise, codes from
|
||||
* ISO 639-2/T are used. REGION specifies an uppercase ISO 3166-1 country/region identifier.
|
||||
* For example, the locale name for English (United States) is "en-US" and the locale name
|
||||
* for Divehi (Maldives) is "dv-MV".
|
||||
*
|
||||
* If the locale is a neutral locale (no region), the LOCALE_SNAME value follows the
|
||||
* pattern <language>. If it is a neutral locale for which the script is significant, the
|
||||
* pattern is <language>-<Script>.
|
||||
*
|
||||
* More at https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx
|
||||
*
|
||||
* Most of the languages we support are neutral locales, so we want to use the language name.
|
||||
* There are three exceptions, zh-CN, zh-TW and pt-BR.
|
||||
*/
|
||||
function getPreferedLocaleName(localeName: string) {
|
||||
switch (localeName) {
|
||||
case "zh-CN":
|
||||
case "zh-TW":
|
||||
case "pt-BR":
|
||||
return localeName;
|
||||
default:
|
||||
return localeName.split("-")[0];
|
||||
}
|
||||
}
|
||||
|
||||
function handleError(err: null | object) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function xmlObjectToString(o: any) {
|
||||
const out: any = {};
|
||||
for (const item of o.LCX.Item[0].Item[0].Item) {
|
||||
let ItemId = item.$.ItemId;
|
||||
let val = item.Str[0].Tgt ? item.Str[0].Tgt[0].Val[0] : item.Str[0].Val[0];
|
||||
|
||||
if (typeof ItemId !== "string" || typeof val !== "string") {
|
||||
console.error("Unexpected XML file structure");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (ItemId.charAt(0) === ";") {
|
||||
ItemId = ItemId.slice(1); // remove leading semicolon
|
||||
}
|
||||
|
||||
val = val.replace(/]5D;/, "]"); // unescape `]`
|
||||
out[ItemId] = val;
|
||||
}
|
||||
return JSON.stringify(out, undefined, 2);
|
||||
}
|
||||
|
||||
|
||||
function ensureDirectoryExists(directoryPath: string, action: () => void) {
|
||||
fs.exists(directoryPath, exists => {
|
||||
if (!exists) {
|
||||
const basePath = path.dirname(directoryPath);
|
||||
if (basePath !== directoryPath) {
|
||||
return ensureDirectoryExists(basePath, () => fs.mkdir(directoryPath, action));
|
||||
}
|
||||
}
|
||||
action();
|
||||
});
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, contents: string) {
|
||||
ensureDirectoryExists(path.dirname(fileName), () => {
|
||||
fs.writeFile(fileName, contents, handleError);
|
||||
});
|
||||
}
|
||||
|
||||
function objectToList(o: Record<string, string>) {
|
||||
const list: { key: string, value: string }[] = [];
|
||||
for (const key in o) {
|
||||
list.push({ key, value: o[key] });
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
function generateLCGFile() {
|
||||
return fs.readFile(diagnosticsMapFilePath, (err, data) => {
|
||||
handleError(err);
|
||||
writeFile(
|
||||
path.join(outputPath, "enu", "diagnosticMessages.generated.json.lcg"),
|
||||
getLCGFileXML(
|
||||
objectToList(JSON.parse(data.toString()))
|
||||
.sort((a, b) => a.key > b.key ? 1 : -1) // lcg sorted by property keys
|
||||
.reduce((s, { key, value }) => s + getItemXML(key, value), "")
|
||||
));
|
||||
});
|
||||
|
||||
function getItemXML(key: string, value: string) {
|
||||
// escape entrt value
|
||||
value = value.replace(/]/, "]5D;");
|
||||
|
||||
return `
|
||||
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[${value}]]></Val>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>`;
|
||||
}
|
||||
|
||||
function getLCGFileXML(items: string) {
|
||||
return `<?xml version="1.0" encoding="utf-8"?>
|
||||
<LCX SchemaVersion="6.0" Name="diagnosticMessages.generated.json" PsrId="306" FileType="1" SrcCul="en-US" xmlns="http://schemas.microsoft.com/locstudio/2006/6/lcx">
|
||||
<OwnedComments>
|
||||
<Cmt Name="Dev" />
|
||||
<Cmt Name="LcxAdmin" />
|
||||
<Cmt Name="Rccx" />
|
||||
</OwnedComments>
|
||||
<Item ItemId=";String Table" ItemType="0" PsrId="306" Leaf="false">
|
||||
<Disp Icon="Expand" Expand="true" Disp="true" LocTbl="false" />
|
||||
<Item ItemId=";Strings" ItemType="0" PsrId="306" Leaf="false">
|
||||
<Disp Icon="Str" Disp="true" LocTbl="false" />${items}
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as xml2js from "xml2js";
|
||||
|
||||
function main(): void {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length !== 3) {
|
||||
console.log("Usage:");
|
||||
console.log("\tnode generateLocalizedDiagnosticMessages.js <lcl source directory> <output directory> <generated diagnostics map file>");
|
||||
return;
|
||||
}
|
||||
|
||||
const inputPath = args[0];
|
||||
const outputPath = args[1];
|
||||
const diagnosticsMapFilePath = args[2];
|
||||
|
||||
// generate the lcg file for enu
|
||||
generateLCGFile();
|
||||
|
||||
// generate other langs
|
||||
fs.readdir(inputPath, (err, files) => {
|
||||
handleError(err);
|
||||
files.forEach(visitDirectory);
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
function visitDirectory(name: string) {
|
||||
const inputFilePath = path.join(inputPath, name, "diagnosticMessages", "diagnosticMessages.generated.json.lcl");
|
||||
|
||||
fs.readFile(inputFilePath, (err, data) => {
|
||||
handleError(err);
|
||||
xml2js.parseString(data.toString(), (err, result) => {
|
||||
handleError(err);
|
||||
if (!result || !result.LCX || !result.LCX.$ || !result.LCX.$.TgtCul) {
|
||||
console.error("Unexpected XML file structure. Expected to find result.LCX.$.TgtCul.");
|
||||
process.exit(1);
|
||||
}
|
||||
const outputDirectoryName = getPreferredLocaleName(result.LCX.$.TgtCul).toLowerCase();
|
||||
if (!outputDirectoryName) {
|
||||
console.error(`Invalid output locale name for '${result.LCX.$.TgtCul}'.`);
|
||||
process.exit(1);
|
||||
}
|
||||
writeFile(path.join(outputPath, outputDirectoryName, "diagnosticMessages.generated.json"), xmlObjectToString(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A locale name is based on the language tagging conventions of RFC 4646 (Windows Vista
|
||||
* and later), and is represented by LOCALE_SNAME.
|
||||
* Generally, the pattern <language>-<REGION> is used. Here, language is a lowercase ISO 639
|
||||
* language code. The codes from ISO 639-1 are used when available. Otherwise, codes from
|
||||
* ISO 639-2/T are used. REGION specifies an uppercase ISO 3166-1 country/region identifier.
|
||||
* For example, the locale name for English (United States) is "en-US" and the locale name
|
||||
* for Divehi (Maldives) is "dv-MV".
|
||||
*
|
||||
* If the locale is a neutral locale (no region), the LOCALE_SNAME value follows the
|
||||
* pattern <language>. If it is a neutral locale for which the script is significant, the
|
||||
* pattern is <language>-<Script>.
|
||||
*
|
||||
* More at https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx
|
||||
*
|
||||
* Most of the languages we support are neutral locales, so we want to use the language name.
|
||||
* There are three exceptions, zh-CN, zh-TW and pt-BR.
|
||||
*/
|
||||
function getPreferredLocaleName(localeName: string) {
|
||||
switch (localeName) {
|
||||
case "zh-CN":
|
||||
case "zh-TW":
|
||||
case "pt-BR":
|
||||
return localeName;
|
||||
default:
|
||||
return localeName.split("-")[0];
|
||||
}
|
||||
}
|
||||
|
||||
function handleError(err: null | object) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function xmlObjectToString(o: any) {
|
||||
const out: any = {};
|
||||
for (const item of o.LCX.Item[0].Item[0].Item) {
|
||||
let ItemId = item.$.ItemId;
|
||||
let val = item.Str[0].Tgt ? item.Str[0].Tgt[0].Val[0] : item.Str[0].Val[0];
|
||||
|
||||
if (typeof ItemId !== "string" || typeof val !== "string") {
|
||||
console.error("Unexpected XML file structure");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (ItemId.charAt(0) === ";") {
|
||||
ItemId = ItemId.slice(1); // remove leading semicolon
|
||||
}
|
||||
|
||||
val = val.replace(/]5D;/, "]"); // unescape `]`
|
||||
out[ItemId] = val;
|
||||
}
|
||||
return JSON.stringify(out, undefined, 2);
|
||||
}
|
||||
|
||||
|
||||
function ensureDirectoryExists(directoryPath: string, action: () => void) {
|
||||
fs.exists(directoryPath, exists => {
|
||||
if (!exists) {
|
||||
const basePath = path.dirname(directoryPath);
|
||||
if (basePath !== directoryPath) {
|
||||
return ensureDirectoryExists(basePath, () => fs.mkdir(directoryPath, action));
|
||||
}
|
||||
}
|
||||
action();
|
||||
});
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, contents: string) {
|
||||
ensureDirectoryExists(path.dirname(fileName), () => {
|
||||
fs.writeFile(fileName, contents, handleError);
|
||||
});
|
||||
}
|
||||
|
||||
function objectToList(o: Record<string, string>) {
|
||||
const list: { key: string, value: string }[] = [];
|
||||
for (const key in o) {
|
||||
list.push({ key, value: o[key] });
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
function generateLCGFile() {
|
||||
return fs.readFile(diagnosticsMapFilePath, (err, data) => {
|
||||
handleError(err);
|
||||
writeFile(
|
||||
path.join(outputPath, "enu", "diagnosticMessages.generated.json.lcg"),
|
||||
getLCGFileXML(
|
||||
objectToList(JSON.parse(data.toString()))
|
||||
.sort((a, b) => a.key > b.key ? 1 : -1) // lcg sorted by property keys
|
||||
.reduce((s, { key, value }) => s + getItemXML(key, value), "")
|
||||
));
|
||||
});
|
||||
|
||||
function getItemXML(key: string, value: string) {
|
||||
// escape entrt value
|
||||
value = value.replace(/]/, "]5D;");
|
||||
|
||||
return `
|
||||
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[${value}]]></Val>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>`;
|
||||
}
|
||||
|
||||
function getLCGFileXML(items: string) {
|
||||
return `<?xml version="1.0" encoding="utf-8"?>
|
||||
<LCX SchemaVersion="6.0" Name="diagnosticMessages.generated.json" PsrId="306" FileType="1" SrcCul="en-US" xmlns="http://schemas.microsoft.com/locstudio/2006/6/lcx">
|
||||
<OwnedComments>
|
||||
<Cmt Name="Dev" />
|
||||
<Cmt Name="LcxAdmin" />
|
||||
<Cmt Name="Rccx" />
|
||||
</OwnedComments>
|
||||
<Item ItemId=";String Table" ItemType="0" PsrId="306" Leaf="false">
|
||||
<Disp Icon="Expand" Expand="true" Disp="true" LocTbl="false" />
|
||||
<Item ItemId=";Strings" ItemType="0" PsrId="306" Leaf="false">
|
||||
<Disp Icon="Str" Disp="true" LocTbl="false" />${items}
|
||||
</Item>
|
||||
</Item>
|
||||
</LCX>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
|
||||
import cp = require("child_process");
|
||||
import Octokit = require("@octokit/rest");
|
||||
|
||||
@@ -35,7 +37,7 @@ gh.authenticate({
|
||||
type: "token",
|
||||
token: process.argv[2]
|
||||
});
|
||||
gh.pullRequests.create({
|
||||
gh.pulls.create({
|
||||
owner: process.env.TARGET_FORK,
|
||||
repo: "TypeScript",
|
||||
maintainer_can_modify: true,
|
||||
@@ -50,7 +52,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
|
||||
}).then(r => {
|
||||
const num = r.data.number;
|
||||
console.log(`Pull request ${num} created.`);
|
||||
return gh.pullRequests.createReviewRequest({
|
||||
return gh.pulls.createReviewRequest({
|
||||
owner: process.env.TARGET_FORK,
|
||||
repo: "TypeScript",
|
||||
number: num,
|
||||
|
||||
@@ -35,8 +35,8 @@ function createCancellationToken(args: string[]): ServerCancellationToken {
|
||||
}
|
||||
// cancellationPipeName is a string without '*' inside that can optionally end with '*'
|
||||
// when client wants to signal cancellation it should create a named pipe with name=<cancellationPipeName>
|
||||
// server will synchronously check the presence of the pipe and treat its existance as indicator that current request should be canceled.
|
||||
// in case if client prefers to use more fine-grained schema than one name for all request it can add '*' to the end of cancelellationPipeName.
|
||||
// server will synchronously check the presence of the pipe and treat its existence as indicator that current request should be canceled.
|
||||
// in case if client prefers to use more fine-grained schema than one name for all request it can add '*' to the end of cancellationPipeName.
|
||||
// in this case pipe name will be build dynamically as <cancellationPipeName><request_seq>.
|
||||
if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") {
|
||||
const namePrefix = cancellationPipeName.slice(0, -1);
|
||||
|
||||
@@ -550,7 +550,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
// We create a return control flow graph for IIFEs and constructors. For constructors
|
||||
// we use the return control flow graph in strict property intialization checks.
|
||||
// we use the return control flow graph in strict property initialization checks.
|
||||
currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined;
|
||||
currentBreakTarget = undefined;
|
||||
currentContinueTarget = undefined;
|
||||
@@ -3445,7 +3445,7 @@ namespace ts {
|
||||
// If a FunctionDeclaration is generator function and is the body of a
|
||||
// transformed async function, then this node can be transformed to a
|
||||
// down-level generator.
|
||||
// Currently we do not support transforming any other generator fucntions
|
||||
// Currently we do not support transforming any other generator functions
|
||||
// down level.
|
||||
if (node.asteriskToken) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ts {
|
||||
currentChangedFilePath: Path | undefined;
|
||||
/**
|
||||
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
|
||||
* These will be commited whenever the iteration through affected files of current changed file is complete
|
||||
* These will be committed whenever the iteration through affected files of current changed file is complete
|
||||
*/
|
||||
currentAffectedFilesSignatures: Map<string> | undefined;
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace ts {
|
||||
*/
|
||||
readonly referencedMap: ReadonlyMap<BuilderState.ReferencedSet> | undefined;
|
||||
/**
|
||||
* Contains the map of exported modules ReferencedSet=exorted module files from the file if module emit is enabled
|
||||
* Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled
|
||||
* Otherwise undefined
|
||||
*/
|
||||
readonly exportedModulesMap: Map<BuilderState.ReferencedSet> | undefined;
|
||||
@@ -268,9 +268,9 @@ namespace ts.BuilderState {
|
||||
*/
|
||||
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map<string>, exportedModulesMapCache?: ComputingExportedModulesMap): ReadonlyArray<SourceFile> {
|
||||
// Since the operation could be cancelled, the signatures are always stored in the cache
|
||||
// They will be commited once it is safe to use them
|
||||
// They will be committed once it is safe to use them
|
||||
// eg when calling this api from tsserver, if there is no cancellation of the operation
|
||||
// In the other cases the affected files signatures are commited only after the iteration through the result is complete
|
||||
// In the other cases the affected files signatures are committed only after the iteration through the result is complete
|
||||
const signatureCache = cacheToUpdateSignature || createMap();
|
||||
const sourceFile = programOfThisState.getSourceFileByPath(path);
|
||||
if (!sourceFile) {
|
||||
|
||||
+440
-242
File diff suppressed because it is too large.
Load diff
@@ -1935,7 +1935,7 @@ namespace ts {
|
||||
|
||||
function directoryOfCombinedPath(fileName: string, basePath: string) {
|
||||
// Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical
|
||||
// until consistient casing errors are reported
|
||||
// until consistent casing errors are reported
|
||||
return getDirectoryPath(getNormalizedAbsolutePath(fileName, basePath));
|
||||
}
|
||||
|
||||
|
||||
@@ -1652,7 +1652,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
|
||||
const detail = "kind" in member && "pos" in member ? "SyntaxKind: " + showSyntaxKind(member as Node) : JSON.stringify(member);
|
||||
const detail = typeof member === "object" && "kind" in member && "pos" in member ? "SyntaxKind: " + showSyntaxKind(member as Node) : JSON.stringify(member);
|
||||
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
|
||||
}
|
||||
|
||||
|
||||
@@ -659,10 +659,6 @@
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
"Ambient const enums are not allowed when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1209
|
||||
},
|
||||
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1210
|
||||
@@ -1023,6 +1019,14 @@
|
||||
"category": "Error",
|
||||
"code": 1353
|
||||
},
|
||||
"'readonly' type modifier is only permitted on array and tuple literal types.": {
|
||||
"category": "Error",
|
||||
"code": 1354
|
||||
},
|
||||
"A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.": {
|
||||
"category": "Error",
|
||||
"code": 1355
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
@@ -2092,15 +2096,15 @@
|
||||
"category": "Error",
|
||||
"code": 2577
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.": {
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`.": {
|
||||
"category": "Error",
|
||||
"code": 2580
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig.": {
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`.": {
|
||||
"category": "Error",
|
||||
"code": 2581
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.": {
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.": {
|
||||
"category": "Error",
|
||||
"code": 2582
|
||||
},
|
||||
@@ -2128,6 +2132,26 @@
|
||||
"category": "Error",
|
||||
"code": 2588
|
||||
},
|
||||
"Type instantiation is excessively deep and possibly infinite.": {
|
||||
"category": "Error",
|
||||
"code": 2589
|
||||
},
|
||||
"Expression produces a union type that is too complex to represent.": {
|
||||
"category": "Error",
|
||||
"code": 2590
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.": {
|
||||
"category": "Error",
|
||||
"code": 2591
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig.": {
|
||||
"category": "Error",
|
||||
"code": 2592
|
||||
},
|
||||
"Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.": {
|
||||
"category": "Error",
|
||||
"code": 2593
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -2553,6 +2577,10 @@
|
||||
"category": "Error",
|
||||
"code": 2747
|
||||
},
|
||||
"Cannot access ambient const enums when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 2748
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -876,8 +876,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode;
|
||||
export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | TypeNode, type?: TypeNode) {
|
||||
export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
|
||||
export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | TypeNode, type?: TypeNode) {
|
||||
const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode;
|
||||
node.operator = typeof operatorOrType === "number" ? operatorOrType : SyntaxKind.KeyOfKeyword;
|
||||
node.type = parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type! : operatorOrType);
|
||||
@@ -2874,7 +2874,7 @@ namespace ts {
|
||||
return node.emitNode = { annotatedNodes: [node] } as EmitNode;
|
||||
}
|
||||
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
const sourceFile = getSourceFileOfNode(getParseTreeNode(getSourceFileOfNode(node)));
|
||||
getOrCreateEmitNode(sourceFile).annotatedNodes!.push(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -2966,6 +2966,7 @@ namespace ts {
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.BigIntKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.UniqueKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
@@ -3055,7 +3056,7 @@ namespace ts {
|
||||
return finishNode(postfix);
|
||||
}
|
||||
|
||||
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword) {
|
||||
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword) {
|
||||
const node = <TypeOperatorNode>createNode(SyntaxKind.TypeOperator);
|
||||
parseExpected(operator);
|
||||
node.operator = operator;
|
||||
@@ -3077,6 +3078,7 @@ namespace ts {
|
||||
switch (operator) {
|
||||
case SyntaxKind.KeyOfKeyword:
|
||||
case SyntaxKind.UniqueKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
return parseTypeOperator(operator);
|
||||
case SyntaxKind.InferKeyword:
|
||||
return parseInferType();
|
||||
|
||||
@@ -230,18 +230,18 @@ namespace ts {
|
||||
const readFileWithCache = (fileName: string): string | undefined => {
|
||||
const key = toPath(fileName);
|
||||
const value = readFileCache.get(key);
|
||||
if (value !== undefined) return value || undefined;
|
||||
if (value !== undefined) return value !== false ? value : undefined;
|
||||
return setReadFileCache(key, fileName);
|
||||
};
|
||||
const setReadFileCache = (key: Path, fileName: string) => {
|
||||
const newValue = originalReadFile.call(host, fileName);
|
||||
readFileCache.set(key, newValue || false);
|
||||
readFileCache.set(key, newValue !== undefined ? newValue : false);
|
||||
return newValue;
|
||||
};
|
||||
host.readFile = fileName => {
|
||||
const key = toPath(fileName);
|
||||
const value = readFileCache.get(key);
|
||||
if (value !== undefined) return value; // could be .d.ts from output
|
||||
if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output
|
||||
if (!fileExtensionIs(fileName, Extension.Json)) {
|
||||
return originalReadFile.call(host, fileName);
|
||||
}
|
||||
|
||||
@@ -661,8 +661,15 @@ namespace ts {
|
||||
let pendingKind!: CommentKind;
|
||||
let pendingHasTrailingNewLine!: boolean;
|
||||
let hasPendingCommentRange = false;
|
||||
let collecting = trailing || pos === 0;
|
||||
let collecting = trailing;
|
||||
let accumulator = initial;
|
||||
if (pos === 0) {
|
||||
collecting = true;
|
||||
const shebang = getShebang(text);
|
||||
if (shebang) {
|
||||
pos = shebang.length;
|
||||
}
|
||||
}
|
||||
scan: while (pos >= 0 && pos < text.length) {
|
||||
const ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
|
||||
@@ -1934,8 +1934,13 @@ namespace ts {
|
||||
case SyntaxKind.ConditionalType:
|
||||
return serializeTypeList([(<ConditionalTypeNode>node).trueType, (<ConditionalTypeNode>node).falseType]);
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeOperator:
|
||||
if ((<TypeOperatorNode>node).operator === SyntaxKind.ReadonlyKeyword) {
|
||||
return serializeTypeNode((<TypeOperatorNode>node).type);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
|
||||
@@ -1233,7 +1233,7 @@ namespace ts {
|
||||
|
||||
export interface TypeOperatorNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeOperator;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
@@ -4063,6 +4063,7 @@ namespace ts {
|
||||
export interface TupleType extends GenericType {
|
||||
minLength: number;
|
||||
hasRestElement: boolean;
|
||||
readonly: boolean;
|
||||
associatedNames?: __String[];
|
||||
}
|
||||
|
||||
@@ -4113,7 +4114,6 @@ namespace ts {
|
||||
templateType?: Type;
|
||||
modifiersType?: Type;
|
||||
resolvedApparentType?: Type;
|
||||
instantiating?: boolean;
|
||||
}
|
||||
|
||||
export interface EvolvingArrayType extends ObjectType {
|
||||
@@ -4340,6 +4340,7 @@ namespace ts {
|
||||
None = 0, // No special inference behaviors
|
||||
NoDefault = 1 << 0, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType)
|
||||
AnyDefault = 1 << 1, // Infer anyType for no inferences (otherwise emptyObjectType)
|
||||
NoFixing = 1 << 2, // Disable type parameter fixing
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4368,6 +4369,7 @@ namespace ts {
|
||||
inferences: InferenceInfo[]; // Inferences made for each type parameter
|
||||
flags: InferenceFlags; // Inference flags
|
||||
compareTypes: TypeComparer; // Type comparer function
|
||||
returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@@ -2514,14 +2514,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration) {
|
||||
if (isInJSFile(node)) {
|
||||
const baseType = getClassExtendsHeritageElement(node);
|
||||
if (baseType && isInJSFile(node)) {
|
||||
// Prefer an @augments tag because it may have type parameters.
|
||||
const tag = getJSDocAugmentsTag(node);
|
||||
if (tag) {
|
||||
return tag.class;
|
||||
}
|
||||
}
|
||||
return getClassExtendsHeritageElement(node);
|
||||
return baseType;
|
||||
}
|
||||
|
||||
export function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration) {
|
||||
@@ -5607,6 +5608,11 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.TypeAssertionExpression;
|
||||
}
|
||||
|
||||
export function isConstTypeReference(node: Node) {
|
||||
return isTypeReferenceNode(node) && isIdentifier(node.typeName) &&
|
||||
node.typeName.escapedText === "const" && !node.typeArguments;
|
||||
}
|
||||
|
||||
export function isParenthesizedExpression(node: Node): node is ParenthesizedExpression {
|
||||
return node.kind === SyntaxKind.ParenthesizedExpression;
|
||||
}
|
||||
|
||||
+13
-10
@@ -375,6 +375,15 @@ namespace fakes {
|
||||
}
|
||||
}
|
||||
|
||||
export type ExpectedDiagnostic = [ts.DiagnosticMessage, ...(string | number)[]];
|
||||
function expectedDiagnosticToText([message, ...args]: ExpectedDiagnostic) {
|
||||
let text = ts.getLocaleSpecificMessage(message);
|
||||
if (args.length) {
|
||||
text = ts.formatStringFromArgs(text, args);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost<ts.BuilderProgram> {
|
||||
createProgram = ts.createAbstractBuilder;
|
||||
now() {
|
||||
@@ -395,16 +404,10 @@ namespace fakes {
|
||||
this.diagnostics.length = 0;
|
||||
}
|
||||
|
||||
assertDiagnosticMessages(...expected: ts.DiagnosticMessage[]) {
|
||||
const actual = this.diagnostics.slice();
|
||||
if (actual.length !== expected.length) {
|
||||
assert.fail<any>(actual, expected, `Diagnostic arrays did not match - got\r\n${actual.map(a => " " + a.messageText).join("\r\n")}\r\nexpected\r\n${expected.map(e => " " + e.message).join("\r\n")}`);
|
||||
}
|
||||
for (let i = 0; i < actual.length; i++) {
|
||||
if (actual[i].code !== expected[i].code) {
|
||||
assert.fail(actual[i].messageText, expected[i].message, `Mismatched error code - expected diagnostic ${i} "${actual[i].messageText}" to match ${expected[i].message}`);
|
||||
}
|
||||
}
|
||||
assertDiagnosticMessages(...expectedDiagnostics: ExpectedDiagnostic[]) {
|
||||
const actual = this.diagnostics.slice().map(d => d.messageText as string);
|
||||
const expected = expectedDiagnostics.map(expectedDiagnosticToText);
|
||||
assert.deepEqual(actual, expected, "Diagnostic arrays did not match");
|
||||
}
|
||||
|
||||
printDiagnostics(header = "== Diagnostics ==") {
|
||||
|
||||
Vendored
+658
-214
File diff suppressed because it is too large.
Load diff
Vendored
+7
@@ -96,6 +96,13 @@ interface Headers {
|
||||
values(): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMap {
|
||||
[Symbol.iterator](): IterableIterator<[BufferSource, MediaKeyStatus]>;
|
||||
entries(): IterableIterator<[BufferSource, MediaKeyStatus]>;
|
||||
keys(): IterableIterator<BufferSource>;
|
||||
values(): IterableIterator<MediaKeyStatus>;
|
||||
}
|
||||
|
||||
interface MediaList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -103,7 +103,7 @@ interface Atomics {
|
||||
* Wakes up sleeping agents that are waiting on the given index of the array, returning the
|
||||
* number of agents that were awoken.
|
||||
*/
|
||||
wake(typedArray: Int32Array, index: number, count: number): number;
|
||||
notify(typedArray: Int32Array, index: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Stores the bitwise XOR of a value with the value at the given position in the array,
|
||||
@@ -115,4 +115,4 @@ interface Atomics {
|
||||
readonly [Symbol.toStringTag]: "Atomics";
|
||||
}
|
||||
|
||||
declare var Atomics: Atomics;
|
||||
declare var Atomics: Atomics;
|
||||
Vendored
+9
-9
@@ -1036,14 +1036,14 @@ interface JSON {
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
@@ -1114,13 +1114,13 @@ interface ReadonlyArray<T> {
|
||||
* @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => boolean, thisArg?: any): boolean;
|
||||
every(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): boolean;
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
some(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => boolean, thisArg?: any): boolean;
|
||||
some(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): boolean;
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
|
||||
@@ -1144,7 +1144,7 @@ interface ReadonlyArray<T> {
|
||||
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => any, thisArg?: any): T[];
|
||||
filter(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => unknown, thisArg?: any): T[];
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
||||
@@ -1451,22 +1451,22 @@ type NonNullable<T> = T extends null | undefined ? never : T;
|
||||
/**
|
||||
* Obtain the parameters of a function type in a tuple
|
||||
*/
|
||||
type Parameters<T extends (...args: any[]) => any> = T extends (...args: infer P) => any ? P : never;
|
||||
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
|
||||
|
||||
/**
|
||||
* Obtain the parameters of a constructor function type in a tuple
|
||||
*/
|
||||
type ConstructorParameters<T extends new (...args: any[]) => any> = T extends new (...args: infer P) => any ? P : never;
|
||||
type ConstructorParameters<T extends new (...args: any) => any> = T extends new (...args: infer P) => any ? P : never;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a function type
|
||||
*/
|
||||
type ReturnType<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : any;
|
||||
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;
|
||||
type InstanceType<T extends new (...args: any) => any> = T extends new (...args: any) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Marker for contextual 'this' type
|
||||
|
||||
Vendored
+159
-25
@@ -154,6 +154,10 @@ interface EventListenerOptions {
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
interface EventSourceInit {
|
||||
withCredentials?: boolean;
|
||||
}
|
||||
|
||||
interface ExtendableEventInit extends EventInit {
|
||||
}
|
||||
|
||||
@@ -455,6 +459,7 @@ interface EventListener {
|
||||
(evt: Event): void;
|
||||
}
|
||||
|
||||
/** The ANGLE_instanced_arrays extension is part of the WebGL API and allows to draw the same object, or groups of similar objects multiple times, if they share the same vertex data, primitive count and type. */
|
||||
interface ANGLE_instanced_arrays {
|
||||
drawArraysInstancedANGLE(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void;
|
||||
drawElementsInstancedANGLE(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, primcount: GLsizei): void;
|
||||
@@ -462,6 +467,7 @@ interface ANGLE_instanced_arrays {
|
||||
readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: GLenum;
|
||||
}
|
||||
|
||||
/** The AbortController interface represents a controller object that allows you to abort one or more DOM requests as and when desired. */
|
||||
interface AbortController {
|
||||
/**
|
||||
* Returns the AbortSignal object associated with this object.
|
||||
@@ -480,16 +486,17 @@ declare var AbortController: {
|
||||
};
|
||||
|
||||
interface AbortSignalEventMap {
|
||||
"abort": ProgressEvent;
|
||||
"abort": Event;
|
||||
}
|
||||
|
||||
/** The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
|
||||
interface AbortSignal extends EventTarget {
|
||||
/**
|
||||
* Returns true if this AbortSignal's AbortController has signaled to abort, and false
|
||||
* otherwise.
|
||||
*/
|
||||
readonly aborted: boolean;
|
||||
onabort: ((this: AbortSignal, ev: ProgressEvent) => any) | null;
|
||||
onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
||||
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
removeEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
||||
@@ -521,6 +528,7 @@ interface AesCmacParams extends Algorithm {
|
||||
length: number;
|
||||
}
|
||||
|
||||
/** A Blob object represents a file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */
|
||||
interface Blob {
|
||||
readonly size: number;
|
||||
readonly type: string;
|
||||
@@ -578,6 +586,7 @@ interface BroadcastChannelEventMap {
|
||||
messageerror: MessageEvent;
|
||||
}
|
||||
|
||||
/** The ByteLengthQueuingStrategy interface of the the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams. */
|
||||
interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> {
|
||||
highWaterMark: number;
|
||||
size(chunk: ArrayBufferView): number;
|
||||
@@ -588,6 +597,7 @@ declare var ByteLengthQueuingStrategy: {
|
||||
new(options: { highWaterMark: number }): ByteLengthQueuingStrategy;
|
||||
};
|
||||
|
||||
/** The Cache interface provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. */
|
||||
interface Cache {
|
||||
add(request: RequestInfo): Promise<void>;
|
||||
addAll(requests: RequestInfo[]): Promise<void>;
|
||||
@@ -603,6 +613,7 @@ declare var Cache: {
|
||||
new(): Cache;
|
||||
};
|
||||
|
||||
/** The CacheStorage interface represents the storage for Cache objects. */
|
||||
interface CacheStorage {
|
||||
delete(cacheName: string): Promise<boolean>;
|
||||
has(cacheName: string): Promise<boolean>;
|
||||
@@ -616,6 +627,7 @@ declare var CacheStorage: {
|
||||
new(): CacheStorage;
|
||||
};
|
||||
|
||||
/** The CanvasGradient interface represents an opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). */
|
||||
interface CanvasGradient {
|
||||
/**
|
||||
* Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset
|
||||
@@ -644,6 +656,7 @@ interface CanvasPath {
|
||||
rect(x: number, y: number, w: number, h: number): void;
|
||||
}
|
||||
|
||||
/** The CanvasPattern interface represents an opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. */
|
||||
interface CanvasPattern {
|
||||
/**
|
||||
* Sets the transformation matrix that will be used when rendering the pattern during a fill or
|
||||
@@ -657,6 +670,7 @@ declare var CanvasPattern: {
|
||||
new(): CanvasPattern;
|
||||
};
|
||||
|
||||
/** The Client interface represents an executable context such as a Worker, or a SharedWorker. Window clients are represented by the more-specific WindowClient. You can get Client/WindowClient objects from methods such as Clients.matchAll() and Clients.get(). */
|
||||
interface Client {
|
||||
readonly id: string;
|
||||
readonly type: ClientTypes;
|
||||
@@ -669,6 +683,7 @@ declare var Client: {
|
||||
new(): Client;
|
||||
};
|
||||
|
||||
/** The Clients interface provides access to Client objects. Access it via self.clients within a service worker. */
|
||||
interface Clients {
|
||||
claim(): Promise<void>;
|
||||
get(id: string): Promise<any>;
|
||||
@@ -681,6 +696,7 @@ declare var Clients: {
|
||||
new(): Clients;
|
||||
};
|
||||
|
||||
/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. */
|
||||
interface CloseEvent extends Event {
|
||||
readonly code: number;
|
||||
readonly reason: string;
|
||||
@@ -703,6 +719,7 @@ interface ConcatParams extends Algorithm {
|
||||
publicInfo?: Uint8Array;
|
||||
}
|
||||
|
||||
/** The Console object provides access to the browser's debugging console (e.g. the Web Console in Firefox). The specifics of how it works varies from browser to browser, but there is a de facto set of features that are typically provided. */
|
||||
interface Console {
|
||||
memory: any;
|
||||
assert(condition?: boolean, message?: string, ...data: any[]): void;
|
||||
@@ -736,6 +753,7 @@ declare var Console: {
|
||||
new(): Console;
|
||||
};
|
||||
|
||||
/** The CountQueuingStrategy interface of the the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams. */
|
||||
interface CountQueuingStrategy extends QueuingStrategy {
|
||||
highWaterMark: number;
|
||||
size(chunk: any): 1;
|
||||
@@ -746,6 +764,7 @@ declare var CountQueuingStrategy: {
|
||||
new(options: { highWaterMark: number }): CountQueuingStrategy;
|
||||
};
|
||||
|
||||
/** The Crypto interface represents basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */
|
||||
interface Crypto {
|
||||
readonly subtle: SubtleCrypto;
|
||||
getRandomValues<T extends Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | null>(array: T): T;
|
||||
@@ -756,6 +775,7 @@ declare var Crypto: {
|
||||
new(): Crypto;
|
||||
};
|
||||
|
||||
/** The CryptoKey interface represents a cryptographic key derived from a specific key algorithm. */
|
||||
interface CryptoKey {
|
||||
readonly algorithm: KeyAlgorithm;
|
||||
readonly extractable: boolean;
|
||||
@@ -782,6 +802,7 @@ declare var CustomEvent: {
|
||||
new<T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
|
||||
};
|
||||
|
||||
/** The DOMException interface represents an abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
|
||||
interface DOMException {
|
||||
readonly code: number;
|
||||
readonly message: string;
|
||||
@@ -921,6 +942,8 @@ interface DOMMatrixReadOnly {
|
||||
rotateFromVector(x?: number, y?: number): DOMMatrix;
|
||||
scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
/** @deprecated */
|
||||
scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix;
|
||||
skewX(sx?: number): DOMMatrix;
|
||||
skewY(sy?: number): DOMMatrix;
|
||||
toFloat32Array(): Float32Array;
|
||||
@@ -1013,6 +1036,7 @@ declare var DOMRectReadOnly: {
|
||||
fromRect(other?: DOMRectInit): DOMRectReadOnly;
|
||||
};
|
||||
|
||||
/** A type returned by some APIs which contains a list of DOMString (strings). */
|
||||
interface DOMStringList {
|
||||
/**
|
||||
* Returns the number of strings in strings.
|
||||
@@ -1039,6 +1063,7 @@ interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
||||
"message": MessageEvent;
|
||||
}
|
||||
|
||||
/** The DedicatedWorkerGlobalScope object (the Worker global scope) is accessible through the self keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers. */
|
||||
interface DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
||||
onmessage: ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null;
|
||||
close(): void;
|
||||
@@ -1078,6 +1103,7 @@ interface EXT_blend_minmax {
|
||||
readonly MIN_EXT: GLenum;
|
||||
}
|
||||
|
||||
/** The EXT_frag_depth extension is part of the WebGL API and enables to set a depth value of a fragment from within the fragment shader. */
|
||||
interface EXT_frag_depth {
|
||||
}
|
||||
|
||||
@@ -1091,11 +1117,13 @@ interface EXT_sRGB {
|
||||
interface EXT_shader_texture_lod {
|
||||
}
|
||||
|
||||
/** The EXT_texture_filter_anisotropic extension is part of the WebGL API and exposes two constants for anisotropic filtering (AF). */
|
||||
interface EXT_texture_filter_anisotropic {
|
||||
readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: GLenum;
|
||||
readonly TEXTURE_MAX_ANISOTROPY_EXT: GLenum;
|
||||
}
|
||||
|
||||
/** The ErrorEvent interface represents events providing information related to errors in scripts or in files. */
|
||||
interface ErrorEvent extends Event {
|
||||
readonly colno: number;
|
||||
readonly error: any;
|
||||
@@ -1109,6 +1137,7 @@ declare var ErrorEvent: {
|
||||
new(type: string, eventInitDict?: ErrorEventInit): ErrorEvent;
|
||||
};
|
||||
|
||||
/** The Event interface represents any event which takes place in the DOM; some are user-generated (such as mouse or keyboard events), while others are generated by APIs (such as events that indicate an animation has finished running, a video has been paused, and so forth). While events are usually triggered by such "external" sources, they can also be triggered programmatically, such as by calling the HTMLElement.click() method of an element, or by defining the event, then sending it to a specified target using EventTarget.dispatchEvent(). There are many types of events, some of which use other interfaces based on the main Event interface. Event itself contains the properties and methods which are common to all events. */
|
||||
interface Event {
|
||||
/**
|
||||
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
|
||||
@@ -1133,6 +1162,8 @@ interface Event {
|
||||
*/
|
||||
readonly isTrusted: boolean;
|
||||
returnValue: boolean;
|
||||
/** @deprecated */
|
||||
readonly srcElement: EventTarget | null;
|
||||
/**
|
||||
* Returns the object to which event is dispatched (its target).
|
||||
*/
|
||||
@@ -1180,28 +1211,50 @@ interface EventListenerObject {
|
||||
handleEvent(evt: Event): void;
|
||||
}
|
||||
|
||||
interface EventSourceEventMap {
|
||||
"error": Event;
|
||||
"message": MessageEvent;
|
||||
"open": Event;
|
||||
}
|
||||
|
||||
interface EventSource extends EventTarget {
|
||||
onerror: ((this: EventSource, ev: Event) => any) | null;
|
||||
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
|
||||
onopen: ((this: EventSource, ev: Event) => any) | null;
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the
|
||||
* values described below.
|
||||
*/
|
||||
readonly readyState: number;
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*/
|
||||
readonly url: string;
|
||||
/**
|
||||
* Returns true if the credentials mode
|
||||
* for connection requests to the URL providing the
|
||||
* event stream is set to "include", and false otherwise.
|
||||
*/
|
||||
readonly withCredentials: boolean;
|
||||
close(): void;
|
||||
readonly CLOSED: number;
|
||||
readonly CONNECTING: number;
|
||||
readonly OPEN: number;
|
||||
onerror: (evt: MessageEvent) => any;
|
||||
onmessage: (evt: MessageEvent) => any;
|
||||
onopen: (evt: MessageEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly url: string;
|
||||
readonly withCredentials: boolean;
|
||||
close(): void;
|
||||
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
removeEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
||||
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
}
|
||||
|
||||
declare var EventSource: {
|
||||
prototype: EventSource;
|
||||
new(url: string, eventSourceInitDict?: EventSourceInit): EventSource;
|
||||
readonly CLOSED: number;
|
||||
readonly CONNECTING: number;
|
||||
readonly OPEN: number;
|
||||
};
|
||||
|
||||
interface EventSourceInit {
|
||||
readonly withCredentials: boolean;
|
||||
}
|
||||
|
||||
/** EventTarget is an interface implemented by objects that can receive events and may have listeners for them. */
|
||||
interface EventTarget {
|
||||
/**
|
||||
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
|
||||
@@ -1230,8 +1283,9 @@ declare var EventTarget: {
|
||||
new(): EventTarget;
|
||||
};
|
||||
|
||||
/** The ExtendableEvent interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries. */
|
||||
interface ExtendableEvent extends Event {
|
||||
waitUntil(f: Promise<any>): void;
|
||||
waitUntil(f: any): void;
|
||||
}
|
||||
|
||||
declare var ExtendableEvent: {
|
||||
@@ -1239,6 +1293,7 @@ declare var ExtendableEvent: {
|
||||
new(type: string, eventInitDict?: ExtendableEventInit): ExtendableEvent;
|
||||
};
|
||||
|
||||
/** The ExtendableMessageEvent interface of the ServiceWorker API represents the event object of a message event fired on a service worker (when a channel message is received on the ServiceWorkerGlobalScope from another context) — extends the lifetime of such events. */
|
||||
interface ExtendableMessageEvent extends ExtendableEvent {
|
||||
readonly data: any;
|
||||
readonly lastEventId: string;
|
||||
@@ -1252,13 +1307,14 @@ declare var ExtendableMessageEvent: {
|
||||
new(type: string, eventInitDict?: ExtendableMessageEventInit): ExtendableMessageEvent;
|
||||
};
|
||||
|
||||
/** This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch. */
|
||||
interface FetchEvent extends ExtendableEvent {
|
||||
readonly clientId: string;
|
||||
readonly preloadResponse: Promise<any>;
|
||||
readonly request: Request;
|
||||
readonly resultingClientId: string;
|
||||
readonly targetClientId: string;
|
||||
respondWith(r: Promise<Response>): void;
|
||||
respondWith(r: Response | Promise<Response>): void;
|
||||
}
|
||||
|
||||
declare var FetchEvent: {
|
||||
@@ -1266,6 +1322,7 @@ declare var FetchEvent: {
|
||||
new(type: string, eventInitDict: FetchEventInit): FetchEvent;
|
||||
};
|
||||
|
||||
/** The File interface provides information about files and allows JavaScript in a web page to access their content. */
|
||||
interface File extends Blob {
|
||||
readonly lastModified: number;
|
||||
readonly name: string;
|
||||
@@ -1276,6 +1333,7 @@ declare var File: {
|
||||
new(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
|
||||
};
|
||||
|
||||
/** An object of this type is returned by the files property of the HTML <input> element; this lets you access the list of files selected with the <input type="file"> element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage. */
|
||||
interface FileList {
|
||||
readonly length: number;
|
||||
item(index: number): File | null;
|
||||
@@ -1296,6 +1354,7 @@ interface FileReaderEventMap {
|
||||
"progress": ProgressEvent;
|
||||
}
|
||||
|
||||
/** The FileReader object lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read. */
|
||||
interface FileReader extends EventTarget {
|
||||
readonly error: DOMException | null;
|
||||
onabort: ((this: FileReader, ev: ProgressEvent) => any) | null;
|
||||
@@ -1328,6 +1387,7 @@ declare var FileReader: {
|
||||
readonly LOADING: number;
|
||||
};
|
||||
|
||||
/** The FileReaderSync interface allows to read File or Blob objects in a synchronous way. */
|
||||
interface FileReaderSync {
|
||||
readAsArrayBuffer(blob: Blob): ArrayBuffer;
|
||||
readAsBinaryString(blob: Blob): string;
|
||||
@@ -1340,6 +1400,7 @@ declare var FileReaderSync: {
|
||||
new(): FileReaderSync;
|
||||
};
|
||||
|
||||
/** The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */
|
||||
interface FormData {
|
||||
append(name: string, value: string | Blob, fileName?: string): void;
|
||||
delete(name: string): void;
|
||||
@@ -1359,6 +1420,7 @@ interface GlobalFetch {
|
||||
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
||||
}
|
||||
|
||||
/** The Headers interface of the Fetch API allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence. */
|
||||
interface Headers {
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string): void;
|
||||
@@ -1382,6 +1444,7 @@ interface HkdfCtrParams extends Algorithm {
|
||||
interface IDBArrayKey extends Array<IDBValidKey> {
|
||||
}
|
||||
|
||||
/** The IDBCursor interface of the IndexedDB API represents a cursor for traversing or iterating over multiple records in a database. */
|
||||
interface IDBCursor {
|
||||
/**
|
||||
* Returns the direction ("next", "nextunique", "prev" or "prevunique")
|
||||
@@ -1392,12 +1455,12 @@ interface IDBCursor {
|
||||
* Returns the key of the cursor.
|
||||
* Throws a "InvalidStateError" DOMException if the cursor is advancing or is finished.
|
||||
*/
|
||||
readonly key: IDBValidKey | IDBKeyRange;
|
||||
readonly key: IDBValidKey;
|
||||
/**
|
||||
* Returns the effective key of the cursor.
|
||||
* Throws a "InvalidStateError" DOMException if the cursor is advancing or is finished.
|
||||
*/
|
||||
readonly primaryKey: IDBValidKey | IDBKeyRange;
|
||||
readonly primaryKey: IDBValidKey;
|
||||
/**
|
||||
* Returns the IDBObjectStore or IDBIndex the cursor was opened from.
|
||||
*/
|
||||
@@ -1411,12 +1474,12 @@ interface IDBCursor {
|
||||
* Advances the cursor to the next record in range matching or
|
||||
* after key.
|
||||
*/
|
||||
continue(key?: IDBValidKey | IDBKeyRange): void;
|
||||
continue(key?: IDBValidKey): void;
|
||||
/**
|
||||
* Advances the cursor to the next record in range matching
|
||||
* or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index.
|
||||
*/
|
||||
continuePrimaryKey(key: IDBValidKey | IDBKeyRange, primaryKey: IDBValidKey | IDBKeyRange): void;
|
||||
continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): void;
|
||||
/**
|
||||
* Delete the record pointed at by the cursor with a new value.
|
||||
* If successful, request's result will be undefined.
|
||||
@@ -1435,6 +1498,7 @@ declare var IDBCursor: {
|
||||
new(): IDBCursor;
|
||||
};
|
||||
|
||||
/** The IDBCursorWithValue interface of the IndexedDB API represents a cursor for traversing or iterating over multiple records in a database. It is the same as the IDBCursor, except that it includes the value property. */
|
||||
interface IDBCursorWithValue extends IDBCursor {
|
||||
/**
|
||||
* Returns the cursor's current value.
|
||||
@@ -1454,6 +1518,7 @@ interface IDBDatabaseEventMap {
|
||||
"versionchange": IDBVersionChangeEvent;
|
||||
}
|
||||
|
||||
/** The IDBDatabase interface of the IndexedDB API provides a connection to a database; you can use an IDBDatabase object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The interface provides the only way to get and manage versions of the database. */
|
||||
interface IDBDatabase extends EventTarget {
|
||||
/**
|
||||
* Returns the name of the database.
|
||||
@@ -1501,6 +1566,7 @@ declare var IDBDatabase: {
|
||||
new(): IDBDatabase;
|
||||
};
|
||||
|
||||
/** In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. For a full working example, see our To-do Notifications app (view example live.) */
|
||||
interface IDBFactory {
|
||||
/**
|
||||
* Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if
|
||||
@@ -1530,6 +1596,7 @@ declare var IDBFactory: {
|
||||
new(): IDBFactory;
|
||||
};
|
||||
|
||||
/** IDBIndex interface of the IndexedDB API provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data. */
|
||||
interface IDBIndex {
|
||||
readonly keyPath: string | string[];
|
||||
readonly multiEntry: boolean;
|
||||
@@ -1590,6 +1657,7 @@ declare var IDBIndex: {
|
||||
new(): IDBIndex;
|
||||
};
|
||||
|
||||
/** A key range can be a single value or a range with upper and lower bounds or endpoints. If the key range has both upper and lower bounds, then it is bounded; if it has no bounds, it is unbounded. A bounded key range can either be open (the endpoints are excluded) or closed (the endpoints are included). To retrieve all keys within a certain range, you can use the following code constructs: */
|
||||
interface IDBKeyRange {
|
||||
/**
|
||||
* Returns lower bound, or undefined if none.
|
||||
@@ -1638,6 +1706,7 @@ declare var IDBKeyRange: {
|
||||
upperBound(upper: any, open?: boolean): IDBKeyRange;
|
||||
};
|
||||
|
||||
/** This example shows a variety of different uses of object stores, from updating the data structure with IDBObjectStore.createIndex inside an onupgradeneeded function, to adding a new item to our object store with IDBObjectStore.add. For a full working example, see our To-do Notifications app (view example live.) */
|
||||
interface IDBObjectStore {
|
||||
/**
|
||||
* Returns true if the store has a key generator, and false otherwise.
|
||||
@@ -1661,7 +1730,7 @@ interface IDBObjectStore {
|
||||
* Returns the associated transaction.
|
||||
*/
|
||||
readonly transaction: IDBTransaction;
|
||||
add(value: any, key?: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey>;
|
||||
add(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
|
||||
/**
|
||||
* Deletes all records in store.
|
||||
* If successful, request's result will
|
||||
@@ -1734,7 +1803,7 @@ interface IDBObjectStore {
|
||||
* null if there were no matching records.
|
||||
*/
|
||||
openKeyCursor(query?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection): IDBRequest<IDBCursor | null>;
|
||||
put(value: any, key?: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey>;
|
||||
put(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;
|
||||
}
|
||||
|
||||
declare var IDBObjectStore: {
|
||||
@@ -1747,6 +1816,7 @@ interface IDBOpenDBRequestEventMap extends IDBRequestEventMap {
|
||||
"upgradeneeded": IDBVersionChangeEvent;
|
||||
}
|
||||
|
||||
/** Also inherits methods from its parents IDBRequest and EventTarget. */
|
||||
interface IDBOpenDBRequest extends IDBRequest<IDBDatabase> {
|
||||
onblocked: ((this: IDBOpenDBRequest, ev: Event) => any) | null;
|
||||
onupgradeneeded: ((this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any) | null;
|
||||
@@ -1766,6 +1836,7 @@ interface IDBRequestEventMap {
|
||||
"success": Event;
|
||||
}
|
||||
|
||||
/** The request object does not initially contain any information about the result of the operation, but once information becomes available, an event is fired on the request, and the information becomes available through the properties of the IDBRequest instance. */
|
||||
interface IDBRequest<T = any> extends EventTarget {
|
||||
/**
|
||||
* When a request is completed, returns the error (a DOMException), or null if the request succeeded. Throws
|
||||
@@ -1857,6 +1928,7 @@ declare var IDBTransaction: {
|
||||
new(): IDBTransaction;
|
||||
};
|
||||
|
||||
/** The IDBVersionChangeEvent interface of the IndexedDB API indicates that the version of the database has changed, as the result of an IDBOpenDBRequest.onupgradeneeded event handler function. */
|
||||
interface IDBVersionChangeEvent extends Event {
|
||||
readonly newVersion: number | null;
|
||||
readonly oldVersion: number;
|
||||
@@ -1898,6 +1970,7 @@ interface ImageBitmapOptions {
|
||||
resizeWidth?: number;
|
||||
}
|
||||
|
||||
/** The ImageData interface represents the underlying pixel data of an area of a <canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData(). It can also be used to set a part of the canvas by using putImageData(). */
|
||||
interface ImageData {
|
||||
/**
|
||||
* Returns the one-dimensional array containing the data in RGBA order, as integers in the
|
||||
@@ -1918,6 +1991,7 @@ declare var ImageData: {
|
||||
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
|
||||
};
|
||||
|
||||
/** The MessageChannel interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties. */
|
||||
interface MessageChannel {
|
||||
readonly port1: MessagePort;
|
||||
readonly port2: MessagePort;
|
||||
@@ -1928,6 +2002,7 @@ declare var MessageChannel: {
|
||||
new(): MessageChannel;
|
||||
};
|
||||
|
||||
/** The MessageEvent interface represents a message received by a target object. */
|
||||
interface MessageEvent extends Event {
|
||||
/**
|
||||
* Returns the data of the message.
|
||||
@@ -1966,6 +2041,7 @@ interface MessagePortEventMap {
|
||||
"messageerror": MessageEvent;
|
||||
}
|
||||
|
||||
/** The MessagePort interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other. */
|
||||
interface MessagePort extends EventTarget {
|
||||
onmessage: ((this: MessagePort, ev: MessageEvent) => any) | null;
|
||||
onmessageerror: ((this: MessagePort, ev: MessageEvent) => any) | null;
|
||||
@@ -2043,6 +2119,7 @@ interface NotificationEventMap {
|
||||
"show": Event;
|
||||
}
|
||||
|
||||
/** The Notification interface of the Notifications API is used to configure and display desktop notifications to the user. */
|
||||
interface Notification extends EventTarget {
|
||||
readonly actions: ReadonlyArray<NotificationAction>;
|
||||
readonly badge: string;
|
||||
@@ -2077,6 +2154,7 @@ declare var Notification: {
|
||||
readonly permission: NotificationPermission;
|
||||
};
|
||||
|
||||
/** The parameter passed into the onnotificationclick handler, the NotificationEvent interface represents a notification click event that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. */
|
||||
interface NotificationEvent extends ExtendableEvent {
|
||||
readonly action: string;
|
||||
readonly notification: Notification;
|
||||
@@ -2087,23 +2165,29 @@ declare var NotificationEvent: {
|
||||
new(type: string, eventInitDict: NotificationEventInit): NotificationEvent;
|
||||
};
|
||||
|
||||
/** The OES_element_index_uint extension is part of the WebGL API and adds support for gl.UNSIGNED_INT types to WebGLRenderingContext.drawElements(). */
|
||||
interface OES_element_index_uint {
|
||||
}
|
||||
|
||||
/** The OES_standard_derivatives extension is part of the WebGL API and adds the GLSL derivative functions dFdx, dFdy, and fwidth. */
|
||||
interface OES_standard_derivatives {
|
||||
readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: GLenum;
|
||||
}
|
||||
|
||||
/** The OES_texture_float extension is part of the WebGL API and exposes floating-point pixel types for textures. */
|
||||
interface OES_texture_float {
|
||||
}
|
||||
|
||||
/** The OES_texture_float_linear extension is part of the WebGL API and allows linear filtering with floating-point pixel types for textures. */
|
||||
interface OES_texture_float_linear {
|
||||
}
|
||||
|
||||
/** The OES_texture_half_float extension is part of the WebGL API and adds texture formats with 16- (aka half float) and 32-bit floating-point components. */
|
||||
interface OES_texture_half_float {
|
||||
readonly HALF_FLOAT_OES: GLenum;
|
||||
}
|
||||
|
||||
/** The OES_texture_half_float_linear extension is part of the WebGL API and allows linear filtering with half floating-point pixel types for textures. */
|
||||
interface OES_texture_half_float_linear {
|
||||
}
|
||||
|
||||
@@ -2115,6 +2199,7 @@ interface OES_vertex_array_object {
|
||||
readonly VERTEX_ARRAY_BINDING_OES: GLenum;
|
||||
}
|
||||
|
||||
/** The Path2D interface of the Canvas 2D API is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. */
|
||||
interface Path2D extends CanvasPath {
|
||||
addPath(path: Path2D, transform?: DOMMatrix2DInit): void;
|
||||
}
|
||||
@@ -2128,6 +2213,7 @@ interface PerformanceEventMap {
|
||||
"resourcetimingbufferfull": Event;
|
||||
}
|
||||
|
||||
/** The Performance interface provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
|
||||
interface Performance extends EventTarget {
|
||||
onresourcetimingbufferfull: ((this: Performance, ev: Event) => any) | null;
|
||||
readonly timeOrigin: number;
|
||||
@@ -2153,6 +2239,7 @@ declare var Performance: {
|
||||
new(): Performance;
|
||||
};
|
||||
|
||||
/** The PerformanceEntry object encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image). */
|
||||
interface PerformanceEntry {
|
||||
readonly duration: number;
|
||||
readonly entryType: string;
|
||||
@@ -2166,6 +2253,7 @@ declare var PerformanceEntry: {
|
||||
new(): PerformanceEntry;
|
||||
};
|
||||
|
||||
/** PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline. */
|
||||
interface PerformanceMark extends PerformanceEntry {
|
||||
}
|
||||
|
||||
@@ -2174,6 +2262,7 @@ declare var PerformanceMark: {
|
||||
new(): PerformanceMark;
|
||||
};
|
||||
|
||||
/** PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline. */
|
||||
interface PerformanceMeasure extends PerformanceEntry {
|
||||
}
|
||||
|
||||
@@ -2204,6 +2293,7 @@ declare var PerformanceObserverEntryList: {
|
||||
new(): PerformanceObserverEntryList;
|
||||
};
|
||||
|
||||
/** The PerformanceResourceTiming interface enables retrieval and analysis of detailed network timing data regarding the loading of an application's resources. An application can use the timing metrics to determine, for example, the length of time it takes to fetch a specific resource, such as an XMLHttpRequest, <SVG>, image, or script. */
|
||||
interface PerformanceResourceTiming extends PerformanceEntry {
|
||||
readonly connectEnd: number;
|
||||
readonly connectStart: number;
|
||||
@@ -2230,6 +2320,7 @@ declare var PerformanceResourceTiming: {
|
||||
new(): PerformanceResourceTiming;
|
||||
};
|
||||
|
||||
/** The ProgressEvent interface represents events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an <img>, <audio>, <video>, <style> or <link>). */
|
||||
interface ProgressEvent extends Event {
|
||||
readonly lengthComputable: boolean;
|
||||
readonly loaded: number;
|
||||
@@ -2251,6 +2342,7 @@ declare var PromiseRejectionEvent: {
|
||||
new(type: string, eventInitDict: PromiseRejectionEventInit): PromiseRejectionEvent;
|
||||
};
|
||||
|
||||
/** The PushEvent interface of the Push API represents a push message that has been received. This event is sent to the global scope of a ServiceWorker. It contains the information sent from an application server to a PushSubscription. */
|
||||
interface PushEvent extends ExtendableEvent {
|
||||
readonly data: PushMessageData | null;
|
||||
}
|
||||
@@ -2260,6 +2352,7 @@ declare var PushEvent: {
|
||||
new(type: string, eventInitDict?: PushEventInit): PushEvent;
|
||||
};
|
||||
|
||||
/** The PushManager interface of the Push API provides a way to receive notifications from third-party servers as well as request URLs for push notifications. */
|
||||
interface PushManager {
|
||||
getSubscription(): Promise<PushSubscription | null>;
|
||||
permissionState(options?: PushSubscriptionOptionsInit): Promise<PushPermissionState>;
|
||||
@@ -2272,6 +2365,7 @@ declare var PushManager: {
|
||||
readonly supportedContentEncodings: ReadonlyArray<string>;
|
||||
};
|
||||
|
||||
/** The PushMessageData interface of the Push API provides methods which let you retrieve the push data sent by a server in various formats. */
|
||||
interface PushMessageData {
|
||||
arrayBuffer(): ArrayBuffer;
|
||||
blob(): Blob;
|
||||
@@ -2284,6 +2378,7 @@ declare var PushMessageData: {
|
||||
new(): PushMessageData;
|
||||
};
|
||||
|
||||
/** The PushSubscription interface of the Push API provides a subcription's URL endpoint and allows unsubscription from a push service. */
|
||||
interface PushSubscription {
|
||||
readonly endpoint: string;
|
||||
readonly expirationTime: number | null;
|
||||
@@ -2326,6 +2421,7 @@ interface ReadableByteStreamController {
|
||||
error(error?: any): void;
|
||||
}
|
||||
|
||||
/** The ReadableStream interface of the Streams API represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */
|
||||
interface ReadableStream<R = any> {
|
||||
readonly locked: boolean;
|
||||
cancel(reason?: any): Promise<void>;
|
||||
@@ -2390,6 +2486,7 @@ declare var ReadableStreamReader: {
|
||||
new(): ReadableStreamReader;
|
||||
};
|
||||
|
||||
/** The Request interface of the Fetch API represents a resource request. */
|
||||
interface Request extends Body {
|
||||
/**
|
||||
* Returns the cache mode associated with request, which is a string indicating
|
||||
@@ -2475,6 +2572,7 @@ declare var Request: {
|
||||
new(input: RequestInfo, init?: RequestInit): Request;
|
||||
};
|
||||
|
||||
/** The Response interface of the Fetch API represents the response to a request. */
|
||||
interface Response extends Body {
|
||||
readonly headers: Headers;
|
||||
readonly ok: boolean;
|
||||
@@ -2498,6 +2596,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
|
||||
"statechange": Event;
|
||||
}
|
||||
|
||||
/** The ServiceWorker interface of the ServiceWorker API provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object. */
|
||||
interface ServiceWorker extends EventTarget, AbstractWorker {
|
||||
onstatechange: ((this: ServiceWorker, ev: Event) => any) | null;
|
||||
readonly scriptURL: string;
|
||||
@@ -2520,6 +2619,7 @@ interface ServiceWorkerContainerEventMap {
|
||||
"messageerror": MessageEvent;
|
||||
}
|
||||
|
||||
/** The ServiceWorkerContainer interface of the ServiceWorker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations. */
|
||||
interface ServiceWorkerContainer extends EventTarget {
|
||||
readonly controller: ServiceWorker | null;
|
||||
oncontrollerchange: ((this: ServiceWorkerContainer, ev: Event) => any) | null;
|
||||
@@ -2554,6 +2654,7 @@ interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
||||
"sync": SyncEvent;
|
||||
}
|
||||
|
||||
/** The ServiceWorkerGlobalScope interface of the ServiceWorker API represents the global execution context of a service worker. */
|
||||
interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
||||
readonly clients: Clients;
|
||||
onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null;
|
||||
@@ -2583,6 +2684,7 @@ interface ServiceWorkerRegistrationEventMap {
|
||||
"updatefound": Event;
|
||||
}
|
||||
|
||||
/** The ServiceWorkerRegistration interface of the ServiceWorker API represents the service worker registration. You register a service worker to control one or more pages that share the same origin. */
|
||||
interface ServiceWorkerRegistration extends EventTarget {
|
||||
readonly active: ServiceWorker | null;
|
||||
readonly installing: ServiceWorker | null;
|
||||
@@ -2618,6 +2720,7 @@ declare var StorageManager: {
|
||||
new(): StorageManager;
|
||||
};
|
||||
|
||||
/** The SubtleCrypto interface represents a set of cryptographic primitives. It is available via the Crypto.subtle properties available in a window context (via Window.crypto). */
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer): PromiseLike<ArrayBuffer>;
|
||||
deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike<ArrayBuffer>;
|
||||
@@ -2644,6 +2747,7 @@ declare var SubtleCrypto: {
|
||||
new(): SubtleCrypto;
|
||||
};
|
||||
|
||||
/** The SyncEvent interface represents a sync action that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. */
|
||||
interface SyncEvent extends ExtendableEvent {
|
||||
readonly lastChance: boolean;
|
||||
readonly tag: string;
|
||||
@@ -2654,6 +2758,7 @@ declare var SyncEvent: {
|
||||
new(type: string, init: SyncEventInit): SyncEvent;
|
||||
};
|
||||
|
||||
/** The SyncManager interface of the the ServiceWorker API provides an interface for registering and listing sync registrations. */
|
||||
interface SyncManager {
|
||||
getTags(): Promise<string[]>;
|
||||
register(tag: string): Promise<void>;
|
||||
@@ -2664,6 +2769,7 @@ declare var SyncManager: {
|
||||
new(): SyncManager;
|
||||
};
|
||||
|
||||
/** The TextDecoder interface represents a decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */
|
||||
interface TextDecoder {
|
||||
/**
|
||||
* Returns encoding's name, lowercased.
|
||||
@@ -2699,6 +2805,7 @@ declare var TextDecoder: {
|
||||
new(label?: string, options?: TextDecoderOptions): TextDecoder;
|
||||
};
|
||||
|
||||
/** TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */
|
||||
interface TextEncoder {
|
||||
/**
|
||||
* Returns "utf-8".
|
||||
@@ -2715,6 +2822,7 @@ declare var TextEncoder: {
|
||||
new(): TextEncoder;
|
||||
};
|
||||
|
||||
/** The TextMetrics interface represents the dimension of a text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
|
||||
interface TextMetrics {
|
||||
readonly actualBoundingBoxAscent: number;
|
||||
readonly actualBoundingBoxDescent: number;
|
||||
@@ -2755,6 +2863,7 @@ interface TransformStreamDefaultController<O = any> {
|
||||
terminate(): void;
|
||||
}
|
||||
|
||||
/** The URL interface represents an object providing static methods used for creating object URLs. */
|
||||
interface URL {
|
||||
hash: string;
|
||||
host: string;
|
||||
@@ -2850,6 +2959,7 @@ interface WEBGL_compressed_texture_astc {
|
||||
readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GLenum;
|
||||
}
|
||||
|
||||
/** The WEBGL_compressed_texture_s3tc extension is part of the WebGL API and exposes four S3TC compressed texture formats. */
|
||||
interface WEBGL_compressed_texture_s3tc {
|
||||
readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum;
|
||||
readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: GLenum;
|
||||
@@ -2864,6 +2974,7 @@ interface WEBGL_compressed_texture_s3tc_srgb {
|
||||
readonly COMPRESSED_SRGB_S3TC_DXT1_EXT: GLenum;
|
||||
}
|
||||
|
||||
/** The WEBGL_debug_renderer_info extension is part of the WebGL API and exposes two constants with information about the graphics driver for debugging purposes. */
|
||||
interface WEBGL_debug_renderer_info {
|
||||
readonly UNMASKED_RENDERER_WEBGL: GLenum;
|
||||
readonly UNMASKED_VENDOR_WEBGL: GLenum;
|
||||
@@ -2873,6 +2984,7 @@ interface WEBGL_debug_shaders {
|
||||
getTranslatedShaderSource(shader: WebGLShader): string;
|
||||
}
|
||||
|
||||
/** The WEBGL_depth_texture extension is part of the WebGL API and defines 2D depth and depth-stencil textures. */
|
||||
interface WEBGL_depth_texture {
|
||||
readonly UNSIGNED_INT_24_8_WEBGL: GLenum;
|
||||
}
|
||||
@@ -2920,6 +3032,7 @@ interface WEBGL_lose_context {
|
||||
restoreContext(): void;
|
||||
}
|
||||
|
||||
/** The WebGLActiveInfo interface is part of the WebGL API and represents the information returned by calling the WebGLRenderingContext.getActiveAttrib() and WebGLRenderingContext.getActiveUniform() methods. */
|
||||
interface WebGLActiveInfo {
|
||||
readonly name: string;
|
||||
readonly size: GLint;
|
||||
@@ -2931,6 +3044,7 @@ declare var WebGLActiveInfo: {
|
||||
new(): WebGLActiveInfo;
|
||||
};
|
||||
|
||||
/** The WebGLBuffer interface is part of the WebGL API and represents an opaque buffer object storing data such as vertices or colors. */
|
||||
interface WebGLBuffer extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -2939,6 +3053,7 @@ declare var WebGLBuffer: {
|
||||
new(): WebGLBuffer;
|
||||
};
|
||||
|
||||
/** The WebContextEvent interface is part of the WebGL API and is an interface for an event that is generated in response to a status change to the WebGL rendering context. */
|
||||
interface WebGLContextEvent extends Event {
|
||||
readonly statusMessage: string;
|
||||
}
|
||||
@@ -2948,6 +3063,7 @@ declare var WebGLContextEvent: {
|
||||
new(type: string, eventInit?: WebGLContextEventInit): WebGLContextEvent;
|
||||
};
|
||||
|
||||
/** The WebGLFramebuffer interface is part of the WebGL API and represents a collection of buffers that serve as a rendering destination. */
|
||||
interface WebGLFramebuffer extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -2964,6 +3080,7 @@ declare var WebGLObject: {
|
||||
new(): WebGLObject;
|
||||
};
|
||||
|
||||
/** The WebGLProgram is part of the WebGL API and is a combination of two compiled WebGLShaders consisting of a vertex shader and a fragment shader (both written in GLSL). */
|
||||
interface WebGLProgram extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -2972,6 +3089,7 @@ declare var WebGLProgram: {
|
||||
new(): WebGLProgram;
|
||||
};
|
||||
|
||||
/** The WebGLRenderbuffer interface is part of the WebGL API and represents a buffer that can contain an image, or can be source or target of an rendering operation. */
|
||||
interface WebGLRenderbuffer extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -2980,6 +3098,7 @@ declare var WebGLRenderbuffer: {
|
||||
new(): WebGLRenderbuffer;
|
||||
};
|
||||
|
||||
/** The WebGLRenderingContext interface provides an interface to the OpenGL ES 2.0 graphics rendering context for the drawing surface of an HTML <canvas> element. */
|
||||
interface WebGLRenderingContext extends WebGLRenderingContextBase {
|
||||
}
|
||||
|
||||
@@ -3398,7 +3517,7 @@ interface WebGLRenderingContextBase {
|
||||
isTexture(texture: WebGLTexture | null): GLboolean;
|
||||
lineWidth(width: GLfloat): void;
|
||||
linkProgram(program: WebGLProgram): void;
|
||||
pixelStorei(pname: GLenum, param: GLint): void;
|
||||
pixelStorei(pname: GLenum, param: GLint | GLboolean): void;
|
||||
polygonOffset(factor: GLfloat, units: GLfloat): void;
|
||||
readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
|
||||
renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei): void;
|
||||
@@ -3746,6 +3865,7 @@ interface WebGLRenderingContextBase {
|
||||
readonly ZERO: GLenum;
|
||||
}
|
||||
|
||||
/** The WebGLShader is part of the WebGL API and can either be a vertex or a fragment shader. A WebGLProgram requires both types of shaders. */
|
||||
interface WebGLShader extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -3754,6 +3874,7 @@ declare var WebGLShader: {
|
||||
new(): WebGLShader;
|
||||
};
|
||||
|
||||
/** The WebGLShaderPrecisionFormat interface is part of the WebGL API and represents the information returned by calling the WebGLRenderingContext.getShaderPrecisionFormat() method. */
|
||||
interface WebGLShaderPrecisionFormat {
|
||||
readonly precision: GLint;
|
||||
readonly rangeMax: GLint;
|
||||
@@ -3765,6 +3886,7 @@ declare var WebGLShaderPrecisionFormat: {
|
||||
new(): WebGLShaderPrecisionFormat;
|
||||
};
|
||||
|
||||
/** The WebGLTexture interface is part of the WebGL API and represents an opaque texture object providing storage and state for texturing operations. */
|
||||
interface WebGLTexture extends WebGLObject {
|
||||
}
|
||||
|
||||
@@ -3773,6 +3895,7 @@ declare var WebGLTexture: {
|
||||
new(): WebGLTexture;
|
||||
};
|
||||
|
||||
/** The WebGLUniformLocation interface is part of the WebGL API and represents the location of a uniform variable in a shader program. */
|
||||
interface WebGLUniformLocation {
|
||||
}
|
||||
|
||||
@@ -3791,6 +3914,7 @@ interface WebSocketEventMap {
|
||||
"open": Event;
|
||||
}
|
||||
|
||||
/** The WebSocket object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. */
|
||||
interface WebSocket extends EventTarget {
|
||||
binaryType: BinaryType;
|
||||
readonly bufferedAmount: number;
|
||||
@@ -3828,6 +3952,7 @@ interface WindowBase64 {
|
||||
btoa(rawString: string): string;
|
||||
}
|
||||
|
||||
/** The WindowClient interface of the ServiceWorker API represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources. */
|
||||
interface WindowClient extends Client {
|
||||
readonly ancestorOrigins: ReadonlyArray<string>;
|
||||
readonly focused: boolean;
|
||||
@@ -3867,6 +3992,7 @@ interface WorkerEventMap extends AbstractWorkerEventMap {
|
||||
"message": MessageEvent;
|
||||
}
|
||||
|
||||
/** The Worker interface of the Web Workers API represents a background task that can be easily created and can send messages back to its creator. Creating a worker is as simple as calling the Worker() constructor and specifying a script to be run in the worker thread. */
|
||||
interface Worker extends EventTarget, AbstractWorker {
|
||||
onmessage: ((this: Worker, ev: MessageEvent) => any) | null;
|
||||
postMessage(message: any, transfer?: Transferable[]): void;
|
||||
@@ -3879,13 +4005,14 @@ interface Worker extends EventTarget, AbstractWorker {
|
||||
|
||||
declare var Worker: {
|
||||
prototype: Worker;
|
||||
new(stringUrl: string, options?: WorkerOptions): Worker;
|
||||
new(stringUrl: string | URL, options?: WorkerOptions): Worker;
|
||||
};
|
||||
|
||||
interface WorkerGlobalScopeEventMap {
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
/** The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop. */
|
||||
interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch, WindowOrWorkerGlobalScope {
|
||||
readonly caches: CacheStorage;
|
||||
readonly isSecureContext: boolean;
|
||||
@@ -3905,6 +4032,7 @@ declare var WorkerGlobalScope: {
|
||||
new(): WorkerGlobalScope;
|
||||
};
|
||||
|
||||
/** The WorkerLocation interface defines the absolute location of the script executed by the Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.location property obtained by calling self.location. */
|
||||
interface WorkerLocation {
|
||||
readonly hash: string;
|
||||
readonly host: string;
|
||||
@@ -3923,6 +4051,7 @@ declare var WorkerLocation: {
|
||||
new(): WorkerLocation;
|
||||
};
|
||||
|
||||
/** The WorkerNavigator interface represents a subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.navigator property obtained by calling window.self.navigator. */
|
||||
interface WorkerNavigator extends NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorStorage {
|
||||
readonly serviceWorker: ServiceWorkerContainer;
|
||||
}
|
||||
@@ -3939,6 +4068,7 @@ interface WorkerUtils extends WindowBase64 {
|
||||
importScripts(...urls: string[]): void;
|
||||
}
|
||||
|
||||
/** The WritableStream interface of the the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing. */
|
||||
interface WritableStream<W = any> {
|
||||
readonly locked: boolean;
|
||||
abort(reason?: any): Promise<void>;
|
||||
@@ -3950,10 +4080,12 @@ declare var WritableStream: {
|
||||
new<W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
||||
};
|
||||
|
||||
/** The WritableStreamDefaultController interface of the the Streams API represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */
|
||||
interface WritableStreamDefaultController {
|
||||
error(error?: any): void;
|
||||
}
|
||||
|
||||
/** The WritableStreamDefaultWriter interface of the the Streams API is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink. */
|
||||
interface WritableStreamDefaultWriter<W = any> {
|
||||
readonly closed: Promise<void>;
|
||||
readonly desiredSize: number | null;
|
||||
@@ -3968,6 +4100,7 @@ interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
|
||||
"readystatechange": Event;
|
||||
}
|
||||
|
||||
/** Use XMLHttpRequest (XHR) objects to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. */
|
||||
interface XMLHttpRequest extends XMLHttpRequestEventTarget {
|
||||
onreadystatechange: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
/**
|
||||
@@ -4042,7 +4175,8 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget {
|
||||
*/
|
||||
overrideMimeType(mime: string): void;
|
||||
/**
|
||||
* Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD.
|
||||
* Initiates the request. The body argument provides the request body, if any,
|
||||
* and is ignored if the request method is GET or HEAD.
|
||||
* Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
|
||||
*/
|
||||
send(body?: BodyInit | null): void;
|
||||
@@ -4259,7 +4393,7 @@ type NotificationDirection = "auto" | "ltr" | "rtl";
|
||||
type NotificationPermission = "default" | "denied" | "granted";
|
||||
type PushEncryptionKeyName = "p256dh" | "auth";
|
||||
type PushPermissionState = "denied" | "granted" | "prompt";
|
||||
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
|
||||
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
||||
type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached";
|
||||
type RequestCredentials = "omit" | "same-origin" | "include";
|
||||
type RequestDestination = "" | "audio" | "audioworklet" | "document" | "embed" | "font" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt";
|
||||
|
||||
@@ -904,7 +904,7 @@ namespace ts.server {
|
||||
|
||||
getPreferences(file: NormalizedPath): protocol.UserPreferences {
|
||||
const info = this.getScriptInfoForNormalizedPath(file);
|
||||
return info && info.getPreferences() || this.hostConfiguration.preferences;
|
||||
return { ...this.hostConfiguration.preferences, ...info && info.getPreferences() };
|
||||
}
|
||||
|
||||
getHostFormatCodeOptions(): FormatCodeSettings {
|
||||
|
||||
@@ -1178,8 +1178,7 @@ namespace ts.server {
|
||||
private getRenameInfo(args: protocol.FileLocationRequestArgs): RenameInfo {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const preferences = this.getHostPreferences();
|
||||
return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: preferences.allowRenameOfImportPath });
|
||||
return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
|
||||
}
|
||||
|
||||
private getProjects(args: protocol.FileRequestArgs, getScriptInfoEnsuringProjectsUptoDate?: boolean, ignoreNoProjectError?: boolean): Projects {
|
||||
@@ -1234,12 +1233,12 @@ namespace ts.server {
|
||||
{ fileName: args.file, pos: position },
|
||||
!!args.findInStrings,
|
||||
!!args.findInComments,
|
||||
this.getHostPreferences()
|
||||
this.getPreferences(file)
|
||||
);
|
||||
if (!simplifiedResult) return locations;
|
||||
|
||||
const defaultProject = this.getDefaultProject(args);
|
||||
const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getHostPreferences().allowRenameOfImportPath }), Debug.assertDefined(this.projectService.getScriptInfo(file)));
|
||||
const renameInfo: protocol.RenameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), Debug.assertDefined(this.projectService.getScriptInfo(file)));
|
||||
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,17 @@ namespace ts.codefix {
|
||||
return !!merged;
|
||||
}));
|
||||
const tag = createJSDocComment(comments.join("\n"), createNodeArray([...(oldTags || emptyArray), ...unmergedNewTags]));
|
||||
changes.insertJsdocCommentBefore(sourceFile, parent, tag);
|
||||
const jsDocNode = parent.kind === SyntaxKind.ArrowFunction ? getJsDocNodeForArrowFunction(parent) : parent;
|
||||
jsDocNode.jsDoc = parent.jsDoc;
|
||||
jsDocNode.jsDocCache = parent.jsDocCache;
|
||||
changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
|
||||
}
|
||||
|
||||
function getJsDocNodeForArrowFunction(signature: ArrowFunction): HasJSDoc {
|
||||
if (signature.parent.kind === SyntaxKind.PropertyDeclaration) {
|
||||
return <HasJSDoc>signature.parent;
|
||||
}
|
||||
return <HasJSDoc>signature.parent.parent;
|
||||
}
|
||||
|
||||
function tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined {
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace ts.FindAllReferences {
|
||||
readonly implementations?: boolean;
|
||||
/**
|
||||
* True to opt in for enhanced renaming of shorthand properties and import/export specifiers.
|
||||
* The options controls the behavior for the whole rename operation; it cannot be changed on a per-file basis.
|
||||
* Default is false for backwards compatibility.
|
||||
*/
|
||||
readonly providePrefixAndSuffixTextForRename?: boolean;
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"unittests/asserts.ts",
|
||||
"unittests/base64.ts",
|
||||
"unittests/builder.ts",
|
||||
"unittests/comments.ts",
|
||||
"unittests/compilerCore.ts",
|
||||
"unittests/convertToBase64.ts",
|
||||
"unittests/customTransforms.ts",
|
||||
|
||||
@@ -5,5 +5,8 @@ namespace ts {
|
||||
assert.throws(() => assert.deepEqual(createNodeArray([], /*hasTrailingComma*/ true), createNodeArray([], /*hasTrailingComma*/ false)));
|
||||
assert.deepEqual(createNodeArray([createIdentifier("A")], /*hasTrailingComma*/ true), createNodeArray([createIdentifier("A")], /*hasTrailingComma*/ true));
|
||||
});
|
||||
it("assertNever on string has correct error", () => {
|
||||
assert.throws(() => Debug.assertNever("hi" as never), "Debug Failure. Illegal value: \"hi\"");
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace ts {
|
||||
describe("comment parsing", () => {
|
||||
const withShebang = `#! node
|
||||
/** comment */
|
||||
// another one
|
||||
;`;
|
||||
const noShebang = `/** comment */
|
||||
// another one
|
||||
;`;
|
||||
const withTrailing = `;/* comment */
|
||||
// another one
|
||||
`;
|
||||
it("skips shebang", () => {
|
||||
const result = getLeadingCommentRanges(withShebang, 0);
|
||||
assert.isDefined(result);
|
||||
assert.strictEqual(result!.length, 2);
|
||||
});
|
||||
|
||||
it("treats all comments at start of file as leading comments", () => {
|
||||
const result = getLeadingCommentRanges(noShebang, 0);
|
||||
assert.isDefined(result);
|
||||
assert.strictEqual(result!.length, 2);
|
||||
});
|
||||
|
||||
it("returns leading comments if position is not 0", () => {
|
||||
const result = getLeadingCommentRanges(withTrailing, 1);
|
||||
assert.isDefined(result);
|
||||
assert.strictEqual(result!.length, 1);
|
||||
assert.strictEqual(result![0].kind, SyntaxKind.SingleLineCommentTrivia);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -400,6 +400,46 @@ namespace Foo {
|
||||
}
|
||||
}).outputText;
|
||||
});
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/24709
|
||||
testBaseline("issue24709", () => {
|
||||
const fs = vfs.createFromFileSystem(Harness.IO, /*caseSensitive*/ true);
|
||||
const transformed = transform(createSourceFile("source.ts", "class X { echo(x: string) { return x; } }", ScriptTarget.ES3), [transformSourceFile]);
|
||||
const transformedSourceFile = transformed.transformed[0];
|
||||
transformed.dispose();
|
||||
const host = new fakes.CompilerHost(fs);
|
||||
host.getSourceFile = () => transformedSourceFile;
|
||||
const program = createProgram(["source.ts"], {
|
||||
target: ScriptTarget.ES3,
|
||||
module: ModuleKind.None,
|
||||
noLib: true
|
||||
}, host);
|
||||
program.emit(transformedSourceFile, (_p, s, b) => host.writeFile("source.js", s, b));
|
||||
return host.readFile("source.js")!.toString();
|
||||
|
||||
function transformSourceFile(context: TransformationContext) {
|
||||
const visitor: Visitor = (node) => {
|
||||
if (isMethodDeclaration(node)) {
|
||||
return updateMethod(
|
||||
node,
|
||||
node.decorators,
|
||||
node.modifiers,
|
||||
node.asteriskToken,
|
||||
createIdentifier("foobar"),
|
||||
node.questionToken,
|
||||
node.typeParameters,
|
||||
node.parameters,
|
||||
node.type,
|
||||
node.body,
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
};
|
||||
return (node: SourceFile) => visitNode(node, visitor);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
namespace ts {
|
||||
let currentTime = 100;
|
||||
|
||||
function getExpectedDiagnosticForProjectsInBuild(...projects: string[]): fakes.ExpectedDiagnostic {
|
||||
return [Diagnostics.Projects_in_this_build_Colon_0, projects.map(p => "\r\n * " + p).join("")];
|
||||
}
|
||||
|
||||
export namespace Sample1 {
|
||||
tick();
|
||||
const projFs = loadProjectFromDisk("tests/projects/sample1");
|
||||
@@ -67,7 +72,11 @@ namespace ts {
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, ["/src/tests"], { dry: true, force: false, verbose: false });
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(Diagnostics.A_non_dry_build_would_build_project_0, Diagnostics.A_non_dry_build_would_build_project_0, Diagnostics.A_non_dry_build_would_build_project_0);
|
||||
host.assertDiagnosticMessages(
|
||||
[Diagnostics.A_non_dry_build_would_build_project_0, "/src/core/tsconfig.json"],
|
||||
[Diagnostics.A_non_dry_build_would_build_project_0, "/src/logic/tsconfig.json"],
|
||||
[Diagnostics.A_non_dry_build_would_build_project_0, "/src/tests/tsconfig.json"]
|
||||
);
|
||||
|
||||
// Check for outputs to not be written. Not an exhaustive list
|
||||
for (const output of allExpectedOutputs) {
|
||||
@@ -86,7 +95,11 @@ namespace ts {
|
||||
host.clearDiagnostics();
|
||||
builder = createSolutionBuilder(host, ["/src/tests"], { dry: true, force: false, verbose: false });
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(Diagnostics.Project_0_is_up_to_date, Diagnostics.Project_0_is_up_to_date, Diagnostics.Project_0_is_up_to_date);
|
||||
host.assertDiagnosticMessages(
|
||||
[Diagnostics.Project_0_is_up_to_date, "/src/core/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_up_to_date, "/src/logic/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_up_to_date, "/src/tests/tsconfig.json"]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,13 +159,15 @@ namespace ts {
|
||||
host.clearDiagnostics();
|
||||
builder.resetBuildContext();
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0);
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"],
|
||||
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
|
||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||
);
|
||||
tick();
|
||||
});
|
||||
|
||||
@@ -161,10 +176,12 @@ namespace ts {
|
||||
host.clearDiagnostics();
|
||||
builder.resetBuildContext();
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2);
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/tests/tsconfig.json", "src/tests/index.ts", "src/tests/index.js"]
|
||||
);
|
||||
tick();
|
||||
});
|
||||
|
||||
@@ -175,11 +192,13 @@ namespace ts {
|
||||
builder.resetBuildContext();
|
||||
builder.buildAllProjects();
|
||||
|
||||
host.assertDiagnosticMessages(Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2,
|
||||
Diagnostics.Building_project_0);
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/index.ts"],
|
||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||
);
|
||||
tick();
|
||||
});
|
||||
|
||||
@@ -190,13 +209,15 @@ namespace ts {
|
||||
builder.resetBuildContext();
|
||||
builder.buildAllProjects();
|
||||
|
||||
host.assertDiagnosticMessages(Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies,
|
||||
Diagnostics.Updating_output_timestamps_of_project_0,
|
||||
Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies,
|
||||
Diagnostics.Updating_output_timestamps_of_project_0);
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/index.ts"],
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/logic/tsconfig.json"],
|
||||
[Diagnostics.Updating_output_timestamps_of_project_0, "/src/logic/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/tests/tsconfig.json"],
|
||||
[Diagnostics.Updating_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -210,14 +231,14 @@ namespace ts {
|
||||
replaceText(fs, "/src/logic/index.ts", "c.multiply(10, 15)", `c.muitply()`);
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(
|
||||
Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Property_0_does_not_exist_on_type_1,
|
||||
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors,
|
||||
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"],
|
||||
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
|
||||
[Diagnostics.Property_0_does_not_exist_on_type_1, "muitply", `typeof import("/src/core/index")`],
|
||||
[Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, "src/tests/tsconfig.json", "src/logic"],
|
||||
[Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, "/src/tests/tsconfig.json", "/src/logic"]
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -281,12 +302,12 @@ export class cNew {}`);
|
||||
const projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite");
|
||||
const allExpectedOutputs = ["/src/tests/dist/src/index.js", "/src/tests/dist/src/index.d.ts", "/src/tests/dist/src/hello.json"];
|
||||
|
||||
function verifyProjectWithResolveJsonModule(configFile: string, ...expectedDiagnosticMessages: DiagnosticMessage[]) {
|
||||
function verifyProjectWithResolveJsonModule(configFile: string, ...expectedDiagnosticMessages: fakes.ExpectedDiagnostic[]) {
|
||||
const fs = projFs.shadow();
|
||||
verifyProjectWithResolveJsonModuleWithFs(fs, configFile, allExpectedOutputs, ...expectedDiagnosticMessages);
|
||||
}
|
||||
|
||||
function verifyProjectWithResolveJsonModuleWithFs(fs: vfs.FileSystem, configFile: string, allExpectedOutputs: ReadonlyArray<string>, ...expectedDiagnosticMessages: DiagnosticMessage[]) {
|
||||
function verifyProjectWithResolveJsonModuleWithFs(fs: vfs.FileSystem, configFile: string, allExpectedOutputs: ReadonlyArray<string>, ...expectedDiagnosticMessages: fakes.ExpectedDiagnostic[]) {
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, [configFile], { dry: false, force: false, verbose: false });
|
||||
builder.buildAllProjects();
|
||||
@@ -300,7 +321,10 @@ export class cNew {}`);
|
||||
}
|
||||
|
||||
it("with resolveJsonModule and include only", () => {
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withInclude.json", Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern);
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withInclude.json", [
|
||||
Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern,
|
||||
"/src/tests/src/hello.json"
|
||||
]);
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and include of *.json along with other include", () => {
|
||||
@@ -415,7 +439,7 @@ export default hello.hello`);
|
||||
"/src/c.ts"
|
||||
];
|
||||
|
||||
function verifyBuild(modifyDiskLayout: (fs: vfs.FileSystem) => void, allExpectedOutputs: ReadonlyArray<string>, expectedDiagnostics: DiagnosticMessage[], expectedFileTraces: ReadonlyArray<string>) {
|
||||
function verifyBuild(modifyDiskLayout: (fs: vfs.FileSystem) => void, allExpectedOutputs: ReadonlyArray<string>, expectedFileTraces: ReadonlyArray<string>, ...expectedDiagnostics: fakes.ExpectedDiagnostic[]) {
|
||||
const fs = projFs.shadow();
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
modifyDiskLayout(fs);
|
||||
@@ -442,11 +466,11 @@ export const b = new A();`);
|
||||
}
|
||||
|
||||
it("verify that it builds correctly", () => {
|
||||
verifyBuild(noop, allExpectedOutputs, emptyArray, expectedFileTraces);
|
||||
verifyBuild(noop, allExpectedOutputs, expectedFileTraces);
|
||||
});
|
||||
|
||||
it("verify that it builds correctly when the referenced project uses different module resolution", () => {
|
||||
verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "classic"), allExpectedOutputs, emptyArray, expectedFileTraces);
|
||||
verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "classic"), allExpectedOutputs, expectedFileTraces);
|
||||
});
|
||||
|
||||
it("verify that it build reports error about module not found with node resolution with external module name", () => {
|
||||
@@ -458,10 +482,25 @@ export const b = new A();`);
|
||||
];
|
||||
verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "node"),
|
||||
allExpectedOutputs,
|
||||
[Diagnostics.Cannot_find_module_0],
|
||||
expectedFileTraces);
|
||||
expectedFileTraces,
|
||||
[Diagnostics.Cannot_find_module_0, "a"],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("unittests:: tsbuild - when tsconfig extends the missing file", () => {
|
||||
const projFs = loadProjectFromDisk("tests/projects/missingExtendedConfig");
|
||||
const fs = projFs.shadow();
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, ["/src/tsconfig.json"], {});
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(
|
||||
[Diagnostics.The_specified_path_does_not_exist_Colon_0, "/src/foobar.json"],
|
||||
[Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, "/src/tsconfig.first.json", "[\"**/*\"]", "[]"],
|
||||
[Diagnostics.The_specified_path_does_not_exist_Colon_0, "/src/foobar.json"],
|
||||
[Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, "/src/tsconfig.second.json", "[\"**/*\"]", "[]"]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export namespace OutFile {
|
||||
@@ -564,7 +603,7 @@ export const b = new A();`);
|
||||
|
||||
host.clearDiagnostics();
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(Diagnostics.The_files_list_in_config_file_0_is_empty);
|
||||
host.assertDiagnosticMessages([Diagnostics.The_files_list_in_config_file_0_is_empty, "/src/no-references/tsconfig.json"]);
|
||||
|
||||
// Check for outputs to not be written.
|
||||
for (const output of allExpectedOutputs) {
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ts.projectSystem {
|
||||
const session = createSession(createServerHost([aTs, bTs]));
|
||||
openFilesForSession([bTs], session);
|
||||
|
||||
// rename fails with allowRenameOfImportPath disabled
|
||||
const response1 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response1, {
|
||||
info: {
|
||||
@@ -16,6 +17,7 @@ namespace ts.projectSystem {
|
||||
locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }],
|
||||
});
|
||||
|
||||
// rename succeeds with allowRenameOfImportPath enabled in host
|
||||
session.getProjectService().setHostConfiguration({ preferences: { allowRenameOfImportPath: true } });
|
||||
const response2 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response2, {
|
||||
@@ -30,6 +32,23 @@ namespace ts.projectSystem {
|
||||
},
|
||||
locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }],
|
||||
});
|
||||
|
||||
// rename succeeds with allowRenameOfImportPath enabled in file
|
||||
session.getProjectService().setHostConfiguration({ preferences: { allowRenameOfImportPath: false } });
|
||||
session.getProjectService().setHostConfiguration({ file: "/b.ts", formatOptions: {}, preferences: { allowRenameOfImportPath: true } });
|
||||
const response3 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response3, {
|
||||
info: {
|
||||
canRename: true,
|
||||
fileToRename: aTs.path,
|
||||
displayName: aTs.path,
|
||||
fullDisplayName: aTs.path,
|
||||
kind: ScriptElementKind.moduleElement,
|
||||
kindModifiers: "",
|
||||
triggerSpan: protocolTextSpanFromSubstring(bTs.content, "a", { index: 1 }),
|
||||
},
|
||||
locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }],
|
||||
});
|
||||
});
|
||||
|
||||
it("works with prefixText and suffixText when enabled", () => {
|
||||
@@ -61,7 +80,7 @@ namespace ts.projectSystem {
|
||||
],
|
||||
});
|
||||
|
||||
// rename with prefixText and suffixText enabled
|
||||
// rename with prefixText and suffixText enabled in host
|
||||
session.getProjectService().setHostConfiguration({ preferences: { providePrefixAndSuffixTextForRename: true } });
|
||||
const response2 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x"));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response2, {
|
||||
@@ -84,6 +103,93 @@ namespace ts.projectSystem {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// rename with prefixText and suffixText enabled for file
|
||||
session.getProjectService().setHostConfiguration({ preferences: { providePrefixAndSuffixTextForRename: false } });
|
||||
session.getProjectService().setHostConfiguration({ file: "/a.ts", formatOptions: {}, preferences: { providePrefixAndSuffixTextForRename: true } });
|
||||
const response3 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x"));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response3, {
|
||||
info: {
|
||||
canRename: true,
|
||||
fileToRename: undefined,
|
||||
displayName: "x",
|
||||
fullDisplayName: "x",
|
||||
kind: ScriptElementKind.constElement,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
triggerSpan: protocolTextSpanFromSubstring(aTs.content, "x"),
|
||||
},
|
||||
locs: [
|
||||
{
|
||||
file: aTs.path,
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x"),
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x", { index: 1 }, { prefixText: "x: " }),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("rename behavior is based on file of rename initiation", () => {
|
||||
const aTs: File = { path: "/a.ts", content: "const x = 1; export { x };" };
|
||||
const bTs: File = { path: "/b.ts", content: `import { x } from "./a"; const y = x + 1;` };
|
||||
const host = createServerHost([aTs, bTs]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([aTs, bTs], session);
|
||||
|
||||
// rename from file with prefixText and suffixText enabled
|
||||
session.getProjectService().setHostConfiguration({ file: "/a.ts", formatOptions: {}, preferences: { providePrefixAndSuffixTextForRename: true } });
|
||||
const response1 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "x"));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response1, {
|
||||
info: {
|
||||
canRename: true,
|
||||
fileToRename: undefined,
|
||||
displayName: "x",
|
||||
fullDisplayName: "x",
|
||||
kind: ScriptElementKind.constElement,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
triggerSpan: protocolTextSpanFromSubstring(aTs.content, "x"),
|
||||
},
|
||||
locs: [
|
||||
{
|
||||
file: aTs.path,
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x"),
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x", { index: 2 }, { suffixText: " as x" }),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// rename from file with prefixText and suffixText disabled
|
||||
const response2 = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, "x"));
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response2, {
|
||||
info: {
|
||||
canRename: true,
|
||||
fileToRename: undefined,
|
||||
displayName: "x",
|
||||
fullDisplayName: "x",
|
||||
kind: ScriptElementKind.alias,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
triggerSpan: protocolTextSpanFromSubstring(bTs.content, "x"),
|
||||
},
|
||||
locs: [
|
||||
{
|
||||
file: bTs.path,
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring(bTs.content, "x"),
|
||||
protocolRenameSpanFromSubstring(bTs.content, "x", { index: 1 })
|
||||
]
|
||||
},
|
||||
{
|
||||
file: aTs.path,
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x"),
|
||||
protocolRenameSpanFromSubstring(aTs.content, "x", { index: 2 }),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
tests/cases/compiler/anonymousModules.ts(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/anonymousModules.ts(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/anonymousModules.ts(1,8): error TS1005: ';' expected.
|
||||
tests/cases/compiler/anonymousModules.ts(4,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/anonymousModules.ts(4,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/anonymousModules.ts(4,9): error TS1005: ';' expected.
|
||||
tests/cases/compiler/anonymousModules.ts(10,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/anonymousModules.ts(10,2): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/anonymousModules.ts(10,9): error TS1005: ';' expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/anonymousModules.ts (6 errors) ====
|
||||
module {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
export var foo = 1;
|
||||
|
||||
module {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
export var bar = 1;
|
||||
@@ -26,7 +26,7 @@ tests/cases/compiler/anonymousModules.ts(10,9): error TS1005: ';' expected.
|
||||
|
||||
module {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
var x = bar;
|
||||
|
||||
+5
-3
@@ -814,7 +814,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypeOperatorNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeOperator;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface IndexedAccessTypeNode extends TypeNode {
|
||||
@@ -2286,6 +2286,7 @@ declare namespace ts {
|
||||
interface TupleType extends GenericType {
|
||||
minLength: number;
|
||||
hasRestElement: boolean;
|
||||
readonly: boolean;
|
||||
associatedNames?: __String[];
|
||||
}
|
||||
interface TupleTypeReference extends TypeReference {
|
||||
@@ -3359,6 +3360,7 @@ declare namespace ts {
|
||||
function isNewExpression(node: Node): node is NewExpression;
|
||||
function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression;
|
||||
function isTypeAssertion(node: Node): node is TypeAssertion;
|
||||
function isConstTypeReference(node: Node): boolean;
|
||||
function isParenthesizedExpression(node: Node): node is ParenthesizedExpression;
|
||||
function skipPartiallyEmittedExpressions(node: Expression): Expression;
|
||||
function skipPartiallyEmittedExpressions(node: Node): Node;
|
||||
@@ -3759,7 +3761,7 @@ declare namespace ts {
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode;
|
||||
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
@@ -8344,7 +8346,7 @@ declare namespace ts.server {
|
||||
excludedFiles: ReadonlyArray<NormalizedPath>;
|
||||
private typeAcquisition;
|
||||
updateGraph(): boolean;
|
||||
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
|
||||
getExcludedFiles(): readonly NormalizedPath[];
|
||||
getTypeAcquisition(): TypeAcquisition;
|
||||
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
|
||||
}
|
||||
|
||||
+4
-2
@@ -814,7 +814,7 @@ declare namespace ts {
|
||||
}
|
||||
interface TypeOperatorNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeOperator;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword;
|
||||
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface IndexedAccessTypeNode extends TypeNode {
|
||||
@@ -2286,6 +2286,7 @@ declare namespace ts {
|
||||
interface TupleType extends GenericType {
|
||||
minLength: number;
|
||||
hasRestElement: boolean;
|
||||
readonly: boolean;
|
||||
associatedNames?: __String[];
|
||||
}
|
||||
interface TupleTypeReference extends TypeReference {
|
||||
@@ -3359,6 +3360,7 @@ declare namespace ts {
|
||||
function isNewExpression(node: Node): node is NewExpression;
|
||||
function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression;
|
||||
function isTypeAssertion(node: Node): node is TypeAssertion;
|
||||
function isConstTypeReference(node: Node): boolean;
|
||||
function isParenthesizedExpression(node: Node): node is ParenthesizedExpression;
|
||||
function skipPartiallyEmittedExpressions(node: Expression): Expression;
|
||||
function skipPartiallyEmittedExpressions(node: Node): Node;
|
||||
@@ -3759,7 +3761,7 @@ declare namespace ts {
|
||||
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
|
||||
function createThisTypeNode(): ThisTypeNode;
|
||||
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
|
||||
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode;
|
||||
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
|
||||
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
|
||||
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
|
||||
|
||||
@@ -30,15 +30,15 @@ const foundNumber: number | undefined = arrayOfStringsNumbersAndBooleans.find(is
|
||||
>isNumber : (x: any) => x is number
|
||||
|
||||
const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean>;
|
||||
>readonlyArrayOfStringsNumbersAndBooleans : ReadonlyArray<string | number | boolean>
|
||||
>arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean> : ReadonlyArray<string | number | boolean>
|
||||
>readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[]
|
||||
>arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean> : readonly (string | number | boolean)[]
|
||||
>arrayOfStringsNumbersAndBooleans : (string | number | boolean)[]
|
||||
|
||||
const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber);
|
||||
>readonlyFoundNumber : number
|
||||
>readonlyArrayOfStringsNumbersAndBooleans.find(isNumber) : number
|
||||
>readonlyArrayOfStringsNumbersAndBooleans.find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => boolean, thisArg?: any): string | number | boolean; }
|
||||
>readonlyArrayOfStringsNumbersAndBooleans : ReadonlyArray<string | number | boolean>
|
||||
>find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => boolean, thisArg?: any): string | number | boolean; }
|
||||
>readonlyArrayOfStringsNumbersAndBooleans.find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; }
|
||||
>readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[]
|
||||
>find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; }
|
||||
>isNumber : (x: any) => x is number
|
||||
|
||||
@@ -4,22 +4,22 @@ const array: number[] = [];
|
||||
>[] : undefined[]
|
||||
|
||||
const readonlyArray: ReadonlyArray<number> = [];
|
||||
>readonlyArray : ReadonlyArray<number>
|
||||
>readonlyArray : readonly number[]
|
||||
>[] : undefined[]
|
||||
|
||||
array.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
>array.flatMap((): ReadonlyArray<number> => []) : number[]
|
||||
>array.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>array.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
|
||||
>array : number[]
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<number>
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => readonly number[]
|
||||
>[] : undefined[]
|
||||
|
||||
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
>readonlyArray.flatMap((): ReadonlyArray<number> => []) : number[]
|
||||
>readonlyArray.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>readonlyArray : ReadonlyArray<number>
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<number>
|
||||
>readonlyArray.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
|
||||
>readonlyArray : readonly number[]
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => readonly number[]
|
||||
>[] : undefined[]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
|
||||
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'.
|
||||
Property 'b' is missing in type 'A' but required in type 'B'.
|
||||
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
|
||||
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'readonly B[]'.
|
||||
Types of property 'concat' are incompatible.
|
||||
Type '{ (...items: ConcatArray<A>[]): A[]; (...items: (A | ConcatArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray<B>[]): B[]; (...items: (B | ConcatArray<B>)[]): B[]; }'.
|
||||
Type 'A[]' is not assignable to type 'B[]'.
|
||||
@@ -22,7 +22,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
|
||||
rra = arb;
|
||||
rrb = ara; // error: 'A' is not assignable to 'B'
|
||||
~~~
|
||||
!!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
|
||||
!!! error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'.
|
||||
!!! error TS2322: Property 'b' is missing in type 'A' but required in type 'B'.
|
||||
!!! related TS2728 tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts:2:21: 'b' is declared here.
|
||||
|
||||
@@ -31,7 +31,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
|
||||
rrb = crb;
|
||||
rrb = cra; // error: 'A' is not assignable to 'B'
|
||||
~~~
|
||||
!!! error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
|
||||
!!! error TS2322: Type 'C<A>' is not assignable to type 'readonly B[]'.
|
||||
!!! error TS2322: Types of property 'concat' are incompatible.
|
||||
!!! error TS2322: Type '{ (...items: ConcatArray<A>[]): A[]; (...items: (A | ConcatArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray<B>[]): B[]; (...items: (B | ConcatArray<B>)[]): B[]; }'.
|
||||
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.
|
||||
|
||||
@@ -26,48 +26,48 @@ declare var crb: C<B>;
|
||||
>crb : C<B>
|
||||
|
||||
declare var rra: ReadonlyArray<A>;
|
||||
>rra : ReadonlyArray<A>
|
||||
>rra : readonly A[]
|
||||
|
||||
declare var rrb: ReadonlyArray<B>;
|
||||
>rrb : ReadonlyArray<B>
|
||||
>rrb : readonly B[]
|
||||
|
||||
rra = ara;
|
||||
>rra = ara : A[]
|
||||
>rra : ReadonlyArray<A>
|
||||
>rra : readonly A[]
|
||||
>ara : A[]
|
||||
|
||||
rrb = arb; // OK, Array<B> is assignable to ReadonlyArray<A>
|
||||
>rrb = arb : B[]
|
||||
>rrb : ReadonlyArray<B>
|
||||
>rrb : readonly B[]
|
||||
>arb : B[]
|
||||
|
||||
rra = arb;
|
||||
>rra = arb : B[]
|
||||
>rra : ReadonlyArray<A>
|
||||
>rra : readonly A[]
|
||||
>arb : B[]
|
||||
|
||||
rrb = ara; // error: 'A' is not assignable to 'B'
|
||||
>rrb = ara : A[]
|
||||
>rrb : ReadonlyArray<B>
|
||||
>rrb : readonly B[]
|
||||
>ara : A[]
|
||||
|
||||
rra = cra;
|
||||
>rra = cra : C<A>
|
||||
>rra : ReadonlyArray<A>
|
||||
>rra : readonly A[]
|
||||
>cra : C<A>
|
||||
|
||||
rra = crb; // OK, C<B> is assignable to ReadonlyArray<A>
|
||||
>rra = crb : C<B>
|
||||
>rra : ReadonlyArray<A>
|
||||
>rra : readonly A[]
|
||||
>crb : C<B>
|
||||
|
||||
rrb = crb;
|
||||
>rrb = crb : C<B>
|
||||
>rrb : ReadonlyArray<B>
|
||||
>rrb : readonly B[]
|
||||
>crb : C<B>
|
||||
|
||||
rrb = cra; // error: 'A' is not assignable to 'B'
|
||||
>rrb = cra : C<A>
|
||||
>rrb : ReadonlyArray<B>
|
||||
>rrb : readonly B[]
|
||||
>cra : C<A>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
interface Array<T> {
|
||||
equalsShallow<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>): boolean;
|
||||
>equalsShallow : <T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean
|
||||
>this : ReadonlyArray<T>
|
||||
>other : ReadonlyArray<T>
|
||||
>equalsShallow : <T>(this: readonly T[], other: readonly T[]) => boolean
|
||||
>this : readonly T[]
|
||||
>other : readonly T[]
|
||||
}
|
||||
|
||||
declare const a: (string | number)[] | null[] | undefined[] | {}[];
|
||||
@@ -19,8 +19,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[];
|
||||
let x = a.equalsShallow(b);
|
||||
>x : boolean
|
||||
>a.equalsShallow(b) : boolean
|
||||
>a.equalsShallow : (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean)
|
||||
>a.equalsShallow : (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean)
|
||||
>a : (string | number)[] | null[] | undefined[] | {}[]
|
||||
>equalsShallow : (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean)
|
||||
>equalsShallow : (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean)
|
||||
>b : (string | number)[] | null[] | undefined[] | {}[]
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
Object.freeze({
|
||||
>Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }>
|
||||
>Object.freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>Object : ObjectConstructor
|
||||
>freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>{ foo() { return Object.freeze('a'); },} : { foo(): string; }
|
||||
|
||||
foo() {
|
||||
@@ -13,9 +13,9 @@ Object.freeze({
|
||||
|
||||
return Object.freeze('a');
|
||||
>Object.freeze('a') : string
|
||||
>Object.freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>Object : ObjectConstructor
|
||||
>freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
|
||||
>'a' : "a"
|
||||
|
||||
},
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/salsa/bug24934.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/conformance/salsa/bug24934.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/bug24934.js (1 errors) ====
|
||||
export function abc(a, b, c) { return 5; }
|
||||
module.exports = { abc };
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
==== tests/cases/conformance/salsa/use.js (0 errors) ====
|
||||
import { abc } from './bug24934';
|
||||
abc(1, 2, 3);
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
tests/cases/conformance/expressions/typeAssertions/constAssertions.ts(44,32): error TS2540: Cannot assign to 'x' because it is a read-only property.
|
||||
tests/cases/conformance/expressions/typeAssertions/constAssertions.ts(61,10): error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
tests/cases/conformance/expressions/typeAssertions/constAssertions.ts(62,10): error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
tests/cases/conformance/expressions/typeAssertions/constAssertions.ts(63,10): error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeAssertions/constAssertions.ts (4 errors) ====
|
||||
let v1 = 'abc' as const;
|
||||
let v2 = `abc` as const;
|
||||
let v3 = 10 as const;
|
||||
let v4 = -10 as const;
|
||||
let v5 = +10 as const;
|
||||
let v6 = 10n as const;
|
||||
let v7 = -10n as const;
|
||||
let v8 = true as const;
|
||||
let v9 = false as const;
|
||||
|
||||
let c1 = 'abc' as const;
|
||||
let c2 = `abc` as const;
|
||||
let c3 = 10 as const;
|
||||
let c4 = -10 as const;
|
||||
let c5 = +10 as const;
|
||||
let c6 = 10n as const;
|
||||
let c7 = -10n as const;
|
||||
let c8 = true as const;
|
||||
let c9 = false as const;
|
||||
|
||||
let vv1 = v1;
|
||||
let vc1 = c1;
|
||||
|
||||
let a1 = [] as const;
|
||||
let a2 = [1, 2, 3] as const;
|
||||
let a3 = [10, 'hello', true] as const;
|
||||
let a4 = [...[1, 2, 3]] as const;
|
||||
let a5 = [1, 2, 3];
|
||||
let a6 = [...a5] as const;
|
||||
let a7 = [...a6];
|
||||
let a8 = ['abc', ...a7] as const;
|
||||
let a9 = [...a8];
|
||||
|
||||
declare let d: { [x: string]: string };
|
||||
|
||||
let o1 = { x: 10, y: 20 } as const;
|
||||
let o2 = { a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } as const;
|
||||
let o3 = { ...o1, ...o2 } as const;
|
||||
let o4 = { a: 1, b: 2 };
|
||||
let o5 = { ...o4 } as const;
|
||||
let o6 = { ...o5 };
|
||||
let o7 = { ...d } as const;
|
||||
let o8 = { ...o7 };
|
||||
let o9 = { x: 10, foo() { this.x = 20 } } as const; // Error
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a read-only property.
|
||||
|
||||
let p1 = (10) as const;
|
||||
let p2 = ((-10)) as const;
|
||||
let p3 = ([(10)]) as const;
|
||||
let p4 = [[[[10]]]] as const;
|
||||
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
|
||||
|
||||
let q1 = <const> 10;
|
||||
let q2 = <const> 'abc';
|
||||
let q3 = <const> true;
|
||||
let q4 = <const> [1, 2, 3];
|
||||
let q5 = <const> { x: 10, y: 20 };
|
||||
|
||||
declare function id<T>(x: T): T;
|
||||
|
||||
let e1 = v1 as const; // Error
|
||||
~~
|
||||
!!! error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
let e2 = (true ? 1 : 0) as const; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
let e3 = id(1) as const; // Error
|
||||
~~~~~
|
||||
!!! error TS1355: A 'const' assertion can only be applied to a string, number, boolean, array, or object literal.
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
//// [constAssertions.ts]
|
||||
let v1 = 'abc' as const;
|
||||
let v2 = `abc` as const;
|
||||
let v3 = 10 as const;
|
||||
let v4 = -10 as const;
|
||||
let v5 = +10 as const;
|
||||
let v6 = 10n as const;
|
||||
let v7 = -10n as const;
|
||||
let v8 = true as const;
|
||||
let v9 = false as const;
|
||||
|
||||
let c1 = 'abc' as const;
|
||||
let c2 = `abc` as const;
|
||||
let c3 = 10 as const;
|
||||
let c4 = -10 as const;
|
||||
let c5 = +10 as const;
|
||||
let c6 = 10n as const;
|
||||
let c7 = -10n as const;
|
||||
let c8 = true as const;
|
||||
let c9 = false as const;
|
||||
|
||||
let vv1 = v1;
|
||||
let vc1 = c1;
|
||||
|
||||
let a1 = [] as const;
|
||||
let a2 = [1, 2, 3] as const;
|
||||
let a3 = [10, 'hello', true] as const;
|
||||
let a4 = [...[1, 2, 3]] as const;
|
||||
let a5 = [1, 2, 3];
|
||||
let a6 = [...a5] as const;
|
||||
let a7 = [...a6];
|
||||
let a8 = ['abc', ...a7] as const;
|
||||
let a9 = [...a8];
|
||||
|
||||
declare let d: { [x: string]: string };
|
||||
|
||||
let o1 = { x: 10, y: 20 } as const;
|
||||
let o2 = { a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } as const;
|
||||
let o3 = { ...o1, ...o2 } as const;
|
||||
let o4 = { a: 1, b: 2 };
|
||||
let o5 = { ...o4 } as const;
|
||||
let o6 = { ...o5 };
|
||||
let o7 = { ...d } as const;
|
||||
let o8 = { ...o7 };
|
||||
let o9 = { x: 10, foo() { this.x = 20 } } as const; // Error
|
||||
|
||||
let p1 = (10) as const;
|
||||
let p2 = ((-10)) as const;
|
||||
let p3 = ([(10)]) as const;
|
||||
let p4 = [[[[10]]]] as const;
|
||||
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
|
||||
|
||||
let q1 = <const> 10;
|
||||
let q2 = <const> 'abc';
|
||||
let q3 = <const> true;
|
||||
let q4 = <const> [1, 2, 3];
|
||||
let q5 = <const> { x: 10, y: 20 };
|
||||
|
||||
declare function id<T>(x: T): T;
|
||||
|
||||
let e1 = v1 as const; // Error
|
||||
let e2 = (true ? 1 : 0) as const; // Error
|
||||
let e3 = id(1) as const; // Error
|
||||
|
||||
|
||||
//// [constAssertions.js]
|
||||
"use strict";
|
||||
let v1 = 'abc';
|
||||
let v2 = `abc`;
|
||||
let v3 = 10;
|
||||
let v4 = -10;
|
||||
let v5 = +10;
|
||||
let v6 = 10n;
|
||||
let v7 = -10n;
|
||||
let v8 = true;
|
||||
let v9 = false;
|
||||
let c1 = 'abc';
|
||||
let c2 = `abc`;
|
||||
let c3 = 10;
|
||||
let c4 = -10;
|
||||
let c5 = +10;
|
||||
let c6 = 10n;
|
||||
let c7 = -10n;
|
||||
let c8 = true;
|
||||
let c9 = false;
|
||||
let vv1 = v1;
|
||||
let vc1 = c1;
|
||||
let a1 = [];
|
||||
let a2 = [1, 2, 3];
|
||||
let a3 = [10, 'hello', true];
|
||||
let a4 = [...[1, 2, 3]];
|
||||
let a5 = [1, 2, 3];
|
||||
let a6 = [...a5];
|
||||
let a7 = [...a6];
|
||||
let a8 = ['abc', ...a7];
|
||||
let a9 = [...a8];
|
||||
let o1 = { x: 10, y: 20 };
|
||||
let o2 = { a: 1, 'b': 2, ['c']: 3, d() { }, ['e' + '']: 4 };
|
||||
let o3 = { ...o1, ...o2 };
|
||||
let o4 = { a: 1, b: 2 };
|
||||
let o5 = { ...o4 };
|
||||
let o6 = { ...o5 };
|
||||
let o7 = { ...d };
|
||||
let o8 = { ...o7 };
|
||||
let o9 = { x: 10, foo() { this.x = 20; } }; // Error
|
||||
let p1 = (10);
|
||||
let p2 = ((-10));
|
||||
let p3 = ([(10)]);
|
||||
let p4 = [[[[10]]]];
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } };
|
||||
let q1 = 10;
|
||||
let q2 = 'abc';
|
||||
let q3 = true;
|
||||
let q4 = [1, 2, 3];
|
||||
let q5 = { x: 10, y: 20 };
|
||||
let e1 = v1; // Error
|
||||
let e2 = (true ? 1 : 0); // Error
|
||||
let e3 = id(1); // Error
|
||||
|
||||
|
||||
//// [constAssertions.d.ts]
|
||||
declare let v1: "abc";
|
||||
declare let v2: "abc";
|
||||
declare let v3: 10;
|
||||
declare let v4: -10;
|
||||
declare let v5: 10;
|
||||
declare let v6: 10n;
|
||||
declare let v7: -10n;
|
||||
declare let v8: true;
|
||||
declare let v9: false;
|
||||
declare let c1: "abc";
|
||||
declare let c2: "abc";
|
||||
declare let c3: 10;
|
||||
declare let c4: -10;
|
||||
declare let c5: 10;
|
||||
declare let c6: 10n;
|
||||
declare let c7: -10n;
|
||||
declare let c8: true;
|
||||
declare let c9: false;
|
||||
declare let vv1: "abc";
|
||||
declare let vc1: "abc";
|
||||
declare let a1: readonly [];
|
||||
declare let a2: readonly [1, 2, 3];
|
||||
declare let a3: readonly [10, "hello", true];
|
||||
declare let a4: readonly (1 | 2 | 3)[];
|
||||
declare let a5: number[];
|
||||
declare let a6: readonly number[];
|
||||
declare let a7: number[];
|
||||
declare let a8: readonly ["abc", ...number[]];
|
||||
declare let a9: (number | "abc")[];
|
||||
declare let d: {
|
||||
[x: string]: string;
|
||||
};
|
||||
declare let o1: {
|
||||
readonly x: 10;
|
||||
readonly y: 20;
|
||||
};
|
||||
declare let o2: {
|
||||
readonly [x: string]: 1 | 2 | 3 | (() => void) | 4;
|
||||
readonly a: 1;
|
||||
readonly 'b': 2;
|
||||
readonly ['c']: 3;
|
||||
readonly d: () => void;
|
||||
};
|
||||
declare let o3: {
|
||||
readonly a: 1;
|
||||
readonly 'b': 2;
|
||||
readonly ['c']: 3;
|
||||
readonly d: () => void;
|
||||
readonly x: 10;
|
||||
readonly y: 20;
|
||||
};
|
||||
declare let o4: {
|
||||
a: number;
|
||||
b: number;
|
||||
};
|
||||
declare let o5: {
|
||||
readonly a: number;
|
||||
readonly b: number;
|
||||
};
|
||||
declare let o6: {
|
||||
a: number;
|
||||
b: number;
|
||||
};
|
||||
declare let o7: {
|
||||
readonly [x: string]: string;
|
||||
};
|
||||
declare let o8: {
|
||||
[x: string]: string;
|
||||
};
|
||||
declare let o9: {
|
||||
readonly x: 10;
|
||||
readonly foo: () => void;
|
||||
};
|
||||
declare let p1: 10;
|
||||
declare let p2: -10;
|
||||
declare let p3: readonly [10];
|
||||
declare let p4: readonly [readonly [readonly [readonly [10]]]];
|
||||
declare let x1: {
|
||||
readonly x: 10;
|
||||
readonly y: readonly [20, 30];
|
||||
z: {
|
||||
a: {
|
||||
readonly b: 42;
|
||||
};
|
||||
};
|
||||
};
|
||||
declare let q1: 10;
|
||||
declare let q2: "abc";
|
||||
declare let q3: true;
|
||||
declare let q4: readonly [1, 2, 3];
|
||||
declare let q5: {
|
||||
readonly x: 10;
|
||||
readonly y: 20;
|
||||
};
|
||||
declare function id<T>(x: T): T;
|
||||
declare let e1: "abc";
|
||||
declare let e2: 0 | 1;
|
||||
declare let e3: 1;
|
||||
@@ -0,0 +1,201 @@
|
||||
=== tests/cases/conformance/expressions/typeAssertions/constAssertions.ts ===
|
||||
let v1 = 'abc' as const;
|
||||
>v1 : Symbol(v1, Decl(constAssertions.ts, 0, 3))
|
||||
|
||||
let v2 = `abc` as const;
|
||||
>v2 : Symbol(v2, Decl(constAssertions.ts, 1, 3))
|
||||
|
||||
let v3 = 10 as const;
|
||||
>v3 : Symbol(v3, Decl(constAssertions.ts, 2, 3))
|
||||
|
||||
let v4 = -10 as const;
|
||||
>v4 : Symbol(v4, Decl(constAssertions.ts, 3, 3))
|
||||
|
||||
let v5 = +10 as const;
|
||||
>v5 : Symbol(v5, Decl(constAssertions.ts, 4, 3))
|
||||
|
||||
let v6 = 10n as const;
|
||||
>v6 : Symbol(v6, Decl(constAssertions.ts, 5, 3))
|
||||
|
||||
let v7 = -10n as const;
|
||||
>v7 : Symbol(v7, Decl(constAssertions.ts, 6, 3))
|
||||
|
||||
let v8 = true as const;
|
||||
>v8 : Symbol(v8, Decl(constAssertions.ts, 7, 3))
|
||||
|
||||
let v9 = false as const;
|
||||
>v9 : Symbol(v9, Decl(constAssertions.ts, 8, 3))
|
||||
|
||||
let c1 = 'abc' as const;
|
||||
>c1 : Symbol(c1, Decl(constAssertions.ts, 10, 3))
|
||||
|
||||
let c2 = `abc` as const;
|
||||
>c2 : Symbol(c2, Decl(constAssertions.ts, 11, 3))
|
||||
|
||||
let c3 = 10 as const;
|
||||
>c3 : Symbol(c3, Decl(constAssertions.ts, 12, 3))
|
||||
|
||||
let c4 = -10 as const;
|
||||
>c4 : Symbol(c4, Decl(constAssertions.ts, 13, 3))
|
||||
|
||||
let c5 = +10 as const;
|
||||
>c5 : Symbol(c5, Decl(constAssertions.ts, 14, 3))
|
||||
|
||||
let c6 = 10n as const;
|
||||
>c6 : Symbol(c6, Decl(constAssertions.ts, 15, 3))
|
||||
|
||||
let c7 = -10n as const;
|
||||
>c7 : Symbol(c7, Decl(constAssertions.ts, 16, 3))
|
||||
|
||||
let c8 = true as const;
|
||||
>c8 : Symbol(c8, Decl(constAssertions.ts, 17, 3))
|
||||
|
||||
let c9 = false as const;
|
||||
>c9 : Symbol(c9, Decl(constAssertions.ts, 18, 3))
|
||||
|
||||
let vv1 = v1;
|
||||
>vv1 : Symbol(vv1, Decl(constAssertions.ts, 20, 3))
|
||||
>v1 : Symbol(v1, Decl(constAssertions.ts, 0, 3))
|
||||
|
||||
let vc1 = c1;
|
||||
>vc1 : Symbol(vc1, Decl(constAssertions.ts, 21, 3))
|
||||
>c1 : Symbol(c1, Decl(constAssertions.ts, 10, 3))
|
||||
|
||||
let a1 = [] as const;
|
||||
>a1 : Symbol(a1, Decl(constAssertions.ts, 23, 3))
|
||||
|
||||
let a2 = [1, 2, 3] as const;
|
||||
>a2 : Symbol(a2, Decl(constAssertions.ts, 24, 3))
|
||||
|
||||
let a3 = [10, 'hello', true] as const;
|
||||
>a3 : Symbol(a3, Decl(constAssertions.ts, 25, 3))
|
||||
|
||||
let a4 = [...[1, 2, 3]] as const;
|
||||
>a4 : Symbol(a4, Decl(constAssertions.ts, 26, 3))
|
||||
|
||||
let a5 = [1, 2, 3];
|
||||
>a5 : Symbol(a5, Decl(constAssertions.ts, 27, 3))
|
||||
|
||||
let a6 = [...a5] as const;
|
||||
>a6 : Symbol(a6, Decl(constAssertions.ts, 28, 3))
|
||||
>a5 : Symbol(a5, Decl(constAssertions.ts, 27, 3))
|
||||
|
||||
let a7 = [...a6];
|
||||
>a7 : Symbol(a7, Decl(constAssertions.ts, 29, 3))
|
||||
>a6 : Symbol(a6, Decl(constAssertions.ts, 28, 3))
|
||||
|
||||
let a8 = ['abc', ...a7] as const;
|
||||
>a8 : Symbol(a8, Decl(constAssertions.ts, 30, 3))
|
||||
>a7 : Symbol(a7, Decl(constAssertions.ts, 29, 3))
|
||||
|
||||
let a9 = [...a8];
|
||||
>a9 : Symbol(a9, Decl(constAssertions.ts, 31, 3))
|
||||
>a8 : Symbol(a8, Decl(constAssertions.ts, 30, 3))
|
||||
|
||||
declare let d: { [x: string]: string };
|
||||
>d : Symbol(d, Decl(constAssertions.ts, 33, 11))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 33, 18))
|
||||
|
||||
let o1 = { x: 10, y: 20 } as const;
|
||||
>o1 : Symbol(o1, Decl(constAssertions.ts, 35, 3))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 35, 10))
|
||||
>y : Symbol(y, Decl(constAssertions.ts, 35, 17))
|
||||
|
||||
let o2 = { a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } as const;
|
||||
>o2 : Symbol(o2, Decl(constAssertions.ts, 36, 3))
|
||||
>a : Symbol(a, Decl(constAssertions.ts, 36, 10))
|
||||
>'b' : Symbol('b', Decl(constAssertions.ts, 36, 16))
|
||||
>['c'] : Symbol(['c'], Decl(constAssertions.ts, 36, 24))
|
||||
>'c' : Symbol(['c'], Decl(constAssertions.ts, 36, 24))
|
||||
>d : Symbol(d, Decl(constAssertions.ts, 36, 34))
|
||||
>['e' + ''] : Symbol(['e' + ''], Decl(constAssertions.ts, 36, 42))
|
||||
|
||||
let o3 = { ...o1, ...o2 } as const;
|
||||
>o3 : Symbol(o3, Decl(constAssertions.ts, 37, 3))
|
||||
>o1 : Symbol(o1, Decl(constAssertions.ts, 35, 3))
|
||||
>o2 : Symbol(o2, Decl(constAssertions.ts, 36, 3))
|
||||
|
||||
let o4 = { a: 1, b: 2 };
|
||||
>o4 : Symbol(o4, Decl(constAssertions.ts, 38, 3))
|
||||
>a : Symbol(a, Decl(constAssertions.ts, 38, 10))
|
||||
>b : Symbol(b, Decl(constAssertions.ts, 38, 16))
|
||||
|
||||
let o5 = { ...o4 } as const;
|
||||
>o5 : Symbol(o5, Decl(constAssertions.ts, 39, 3))
|
||||
>o4 : Symbol(o4, Decl(constAssertions.ts, 38, 3))
|
||||
|
||||
let o6 = { ...o5 };
|
||||
>o6 : Symbol(o6, Decl(constAssertions.ts, 40, 3))
|
||||
>o5 : Symbol(o5, Decl(constAssertions.ts, 39, 3))
|
||||
|
||||
let o7 = { ...d } as const;
|
||||
>o7 : Symbol(o7, Decl(constAssertions.ts, 41, 3))
|
||||
>d : Symbol(d, Decl(constAssertions.ts, 33, 11))
|
||||
|
||||
let o8 = { ...o7 };
|
||||
>o8 : Symbol(o8, Decl(constAssertions.ts, 42, 3))
|
||||
>o7 : Symbol(o7, Decl(constAssertions.ts, 41, 3))
|
||||
|
||||
let o9 = { x: 10, foo() { this.x = 20 } } as const; // Error
|
||||
>o9 : Symbol(o9, Decl(constAssertions.ts, 43, 3))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 43, 10))
|
||||
>foo : Symbol(foo, Decl(constAssertions.ts, 43, 17))
|
||||
>this.x : Symbol(x, Decl(constAssertions.ts, 43, 10))
|
||||
>this : Symbol(__object, Decl(constAssertions.ts, 43, 8))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 43, 10))
|
||||
|
||||
let p1 = (10) as const;
|
||||
>p1 : Symbol(p1, Decl(constAssertions.ts, 45, 3))
|
||||
|
||||
let p2 = ((-10)) as const;
|
||||
>p2 : Symbol(p2, Decl(constAssertions.ts, 46, 3))
|
||||
|
||||
let p3 = ([(10)]) as const;
|
||||
>p3 : Symbol(p3, Decl(constAssertions.ts, 47, 3))
|
||||
|
||||
let p4 = [[[[10]]]] as const;
|
||||
>p4 : Symbol(p4, Decl(constAssertions.ts, 48, 3))
|
||||
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
|
||||
>x1 : Symbol(x1, Decl(constAssertions.ts, 50, 3))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 50, 10))
|
||||
>y : Symbol(y, Decl(constAssertions.ts, 50, 17))
|
||||
>z : Symbol(z, Decl(constAssertions.ts, 50, 30))
|
||||
>a : Symbol(a, Decl(constAssertions.ts, 50, 35))
|
||||
>b : Symbol(b, Decl(constAssertions.ts, 50, 40))
|
||||
|
||||
let q1 = <const> 10;
|
||||
>q1 : Symbol(q1, Decl(constAssertions.ts, 52, 3))
|
||||
|
||||
let q2 = <const> 'abc';
|
||||
>q2 : Symbol(q2, Decl(constAssertions.ts, 53, 3))
|
||||
|
||||
let q3 = <const> true;
|
||||
>q3 : Symbol(q3, Decl(constAssertions.ts, 54, 3))
|
||||
|
||||
let q4 = <const> [1, 2, 3];
|
||||
>q4 : Symbol(q4, Decl(constAssertions.ts, 55, 3))
|
||||
|
||||
let q5 = <const> { x: 10, y: 20 };
|
||||
>q5 : Symbol(q5, Decl(constAssertions.ts, 56, 3))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 56, 18))
|
||||
>y : Symbol(y, Decl(constAssertions.ts, 56, 25))
|
||||
|
||||
declare function id<T>(x: T): T;
|
||||
>id : Symbol(id, Decl(constAssertions.ts, 56, 34))
|
||||
>T : Symbol(T, Decl(constAssertions.ts, 58, 20))
|
||||
>x : Symbol(x, Decl(constAssertions.ts, 58, 23))
|
||||
>T : Symbol(T, Decl(constAssertions.ts, 58, 20))
|
||||
>T : Symbol(T, Decl(constAssertions.ts, 58, 20))
|
||||
|
||||
let e1 = v1 as const; // Error
|
||||
>e1 : Symbol(e1, Decl(constAssertions.ts, 60, 3))
|
||||
>v1 : Symbol(v1, Decl(constAssertions.ts, 0, 3))
|
||||
|
||||
let e2 = (true ? 1 : 0) as const; // Error
|
||||
>e2 : Symbol(e2, Decl(constAssertions.ts, 61, 3))
|
||||
|
||||
let e3 = id(1) as const; // Error
|
||||
>e3 : Symbol(e3, Decl(constAssertions.ts, 62, 3))
|
||||
>id : Symbol(id, Decl(constAssertions.ts, 56, 34))
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
=== tests/cases/conformance/expressions/typeAssertions/constAssertions.ts ===
|
||||
let v1 = 'abc' as const;
|
||||
>v1 : "abc"
|
||||
>'abc' as const : "abc"
|
||||
>'abc' : "abc"
|
||||
|
||||
let v2 = `abc` as const;
|
||||
>v2 : "abc"
|
||||
>`abc` as const : "abc"
|
||||
>`abc` : "abc"
|
||||
|
||||
let v3 = 10 as const;
|
||||
>v3 : 10
|
||||
>10 as const : 10
|
||||
>10 : 10
|
||||
|
||||
let v4 = -10 as const;
|
||||
>v4 : -10
|
||||
>-10 as const : -10
|
||||
>-10 : -10
|
||||
>10 : 10
|
||||
|
||||
let v5 = +10 as const;
|
||||
>v5 : 10
|
||||
>+10 as const : 10
|
||||
>+10 : 10
|
||||
>10 : 10
|
||||
|
||||
let v6 = 10n as const;
|
||||
>v6 : 10n
|
||||
>10n as const : 10n
|
||||
>10n : 10n
|
||||
|
||||
let v7 = -10n as const;
|
||||
>v7 : -10n
|
||||
>-10n as const : -10n
|
||||
>-10n : -10n
|
||||
>10n : 10n
|
||||
|
||||
let v8 = true as const;
|
||||
>v8 : true
|
||||
>true as const : true
|
||||
>true : true
|
||||
|
||||
let v9 = false as const;
|
||||
>v9 : false
|
||||
>false as const : false
|
||||
>false : false
|
||||
|
||||
let c1 = 'abc' as const;
|
||||
>c1 : "abc"
|
||||
>'abc' as const : "abc"
|
||||
>'abc' : "abc"
|
||||
|
||||
let c2 = `abc` as const;
|
||||
>c2 : "abc"
|
||||
>`abc` as const : "abc"
|
||||
>`abc` : "abc"
|
||||
|
||||
let c3 = 10 as const;
|
||||
>c3 : 10
|
||||
>10 as const : 10
|
||||
>10 : 10
|
||||
|
||||
let c4 = -10 as const;
|
||||
>c4 : -10
|
||||
>-10 as const : -10
|
||||
>-10 : -10
|
||||
>10 : 10
|
||||
|
||||
let c5 = +10 as const;
|
||||
>c5 : 10
|
||||
>+10 as const : 10
|
||||
>+10 : 10
|
||||
>10 : 10
|
||||
|
||||
let c6 = 10n as const;
|
||||
>c6 : 10n
|
||||
>10n as const : 10n
|
||||
>10n : 10n
|
||||
|
||||
let c7 = -10n as const;
|
||||
>c7 : -10n
|
||||
>-10n as const : -10n
|
||||
>-10n : -10n
|
||||
>10n : 10n
|
||||
|
||||
let c8 = true as const;
|
||||
>c8 : true
|
||||
>true as const : true
|
||||
>true : true
|
||||
|
||||
let c9 = false as const;
|
||||
>c9 : false
|
||||
>false as const : false
|
||||
>false : false
|
||||
|
||||
let vv1 = v1;
|
||||
>vv1 : "abc"
|
||||
>v1 : "abc"
|
||||
|
||||
let vc1 = c1;
|
||||
>vc1 : "abc"
|
||||
>c1 : "abc"
|
||||
|
||||
let a1 = [] as const;
|
||||
>a1 : readonly []
|
||||
>[] as const : readonly []
|
||||
>[] : readonly []
|
||||
|
||||
let a2 = [1, 2, 3] as const;
|
||||
>a2 : readonly [1, 2, 3]
|
||||
>[1, 2, 3] as const : readonly [1, 2, 3]
|
||||
>[1, 2, 3] : readonly [1, 2, 3]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
let a3 = [10, 'hello', true] as const;
|
||||
>a3 : readonly [10, "hello", true]
|
||||
>[10, 'hello', true] as const : readonly [10, "hello", true]
|
||||
>[10, 'hello', true] : readonly [10, "hello", true]
|
||||
>10 : 10
|
||||
>'hello' : "hello"
|
||||
>true : true
|
||||
|
||||
let a4 = [...[1, 2, 3]] as const;
|
||||
>a4 : readonly (1 | 2 | 3)[]
|
||||
>[...[1, 2, 3]] as const : readonly (1 | 2 | 3)[]
|
||||
>[...[1, 2, 3]] : readonly (1 | 2 | 3)[]
|
||||
>...[1, 2, 3] : 1 | 2 | 3
|
||||
>[1, 2, 3] : readonly [1, 2, 3]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
let a5 = [1, 2, 3];
|
||||
>a5 : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
let a6 = [...a5] as const;
|
||||
>a6 : readonly number[]
|
||||
>[...a5] as const : readonly number[]
|
||||
>[...a5] : readonly number[]
|
||||
>...a5 : number
|
||||
>a5 : number[]
|
||||
|
||||
let a7 = [...a6];
|
||||
>a7 : number[]
|
||||
>[...a6] : number[]
|
||||
>...a6 : number
|
||||
>a6 : readonly number[]
|
||||
|
||||
let a8 = ['abc', ...a7] as const;
|
||||
>a8 : readonly ["abc", ...number[]]
|
||||
>['abc', ...a7] as const : readonly ["abc", ...number[]]
|
||||
>['abc', ...a7] : readonly ["abc", ...number[]]
|
||||
>'abc' : "abc"
|
||||
>...a7 : number
|
||||
>a7 : number[]
|
||||
|
||||
let a9 = [...a8];
|
||||
>a9 : (number | "abc")[]
|
||||
>[...a8] : (number | "abc")[]
|
||||
>...a8 : number | "abc"
|
||||
>a8 : readonly ["abc", ...number[]]
|
||||
|
||||
declare let d: { [x: string]: string };
|
||||
>d : { [x: string]: string; }
|
||||
>x : string
|
||||
|
||||
let o1 = { x: 10, y: 20 } as const;
|
||||
>o1 : { readonly x: 10; readonly y: 20; }
|
||||
>{ x: 10, y: 20 } as const : { readonly x: 10; readonly y: 20; }
|
||||
>{ x: 10, y: 20 } : { readonly x: 10; readonly y: 20; }
|
||||
>x : 10
|
||||
>10 : 10
|
||||
>y : 20
|
||||
>20 : 20
|
||||
|
||||
let o2 = { a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } as const;
|
||||
>o2 : { readonly [x: string]: 1 | 2 | 3 | (() => void) | 4; readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; }
|
||||
>{ a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } as const : { readonly [x: string]: 1 | 2 | 3 | (() => void) | 4; readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; }
|
||||
>{ a: 1, 'b': 2, ['c']: 3, d() {}, ['e' + '']: 4 } : { readonly [x: string]: 1 | 2 | 3 | (() => void) | 4; readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; }
|
||||
>a : 1
|
||||
>1 : 1
|
||||
>'b' : 2
|
||||
>2 : 2
|
||||
>['c'] : 3
|
||||
>'c' : "c"
|
||||
>3 : 3
|
||||
>d : () => void
|
||||
>['e' + ''] : 4
|
||||
>'e' + '' : string
|
||||
>'e' : "e"
|
||||
>'' : ""
|
||||
>4 : 4
|
||||
|
||||
let o3 = { ...o1, ...o2 } as const;
|
||||
>o3 : { readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; readonly x: 10; readonly y: 20; }
|
||||
>{ ...o1, ...o2 } as const : { readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; readonly x: 10; readonly y: 20; }
|
||||
>{ ...o1, ...o2 } : { readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; readonly x: 10; readonly y: 20; }
|
||||
>o1 : { readonly x: 10; readonly y: 20; }
|
||||
>o2 : { readonly [x: string]: 1 | 2 | 3 | (() => void) | 4; readonly a: 1; readonly 'b': 2; readonly ['c']: 3; readonly d: () => void; }
|
||||
|
||||
let o4 = { a: 1, b: 2 };
|
||||
>o4 : { a: number; b: number; }
|
||||
>{ a: 1, b: 2 } : { a: number; b: number; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : number
|
||||
>2 : 2
|
||||
|
||||
let o5 = { ...o4 } as const;
|
||||
>o5 : { readonly a: number; readonly b: number; }
|
||||
>{ ...o4 } as const : { readonly a: number; readonly b: number; }
|
||||
>{ ...o4 } : { readonly a: number; readonly b: number; }
|
||||
>o4 : { a: number; b: number; }
|
||||
|
||||
let o6 = { ...o5 };
|
||||
>o6 : { a: number; b: number; }
|
||||
>{ ...o5 } : { a: number; b: number; }
|
||||
>o5 : { readonly a: number; readonly b: number; }
|
||||
|
||||
let o7 = { ...d } as const;
|
||||
>o7 : { readonly [x: string]: string; }
|
||||
>{ ...d } as const : { readonly [x: string]: string; }
|
||||
>{ ...d } : { readonly [x: string]: string; }
|
||||
>d : { [x: string]: string; }
|
||||
|
||||
let o8 = { ...o7 };
|
||||
>o8 : { [x: string]: string; }
|
||||
>{ ...o7 } : { [x: string]: string; }
|
||||
>o7 : { readonly [x: string]: string; }
|
||||
|
||||
let o9 = { x: 10, foo() { this.x = 20 } } as const; // Error
|
||||
>o9 : { readonly x: 10; readonly foo: () => void; }
|
||||
>{ x: 10, foo() { this.x = 20 } } as const : { readonly x: 10; readonly foo: () => void; }
|
||||
>{ x: 10, foo() { this.x = 20 } } : { readonly x: 10; readonly foo: () => void; }
|
||||
>x : 10
|
||||
>10 : 10
|
||||
>foo : () => void
|
||||
>this.x = 20 : 20
|
||||
>this.x : any
|
||||
>this : { readonly x: 10; readonly foo: () => void; }
|
||||
>x : any
|
||||
>20 : 20
|
||||
|
||||
let p1 = (10) as const;
|
||||
>p1 : 10
|
||||
>(10) as const : 10
|
||||
>(10) : 10
|
||||
>10 : 10
|
||||
|
||||
let p2 = ((-10)) as const;
|
||||
>p2 : -10
|
||||
>((-10)) as const : -10
|
||||
>((-10)) : -10
|
||||
>(-10) : -10
|
||||
>-10 : -10
|
||||
>10 : 10
|
||||
|
||||
let p3 = ([(10)]) as const;
|
||||
>p3 : readonly [10]
|
||||
>([(10)]) as const : readonly [10]
|
||||
>([(10)]) : readonly [10]
|
||||
>[(10)] : readonly [10]
|
||||
>(10) : 10
|
||||
>10 : 10
|
||||
|
||||
let p4 = [[[[10]]]] as const;
|
||||
>p4 : readonly [readonly [readonly [readonly [10]]]]
|
||||
>[[[[10]]]] as const : readonly [readonly [readonly [readonly [10]]]]
|
||||
>[[[[10]]]] : readonly [readonly [readonly [readonly [10]]]]
|
||||
>[[[10]]] : readonly [readonly [readonly [10]]]
|
||||
>[[10]] : readonly [readonly [10]]
|
||||
>[10] : readonly [10]
|
||||
>10 : 10
|
||||
|
||||
let x1 = { x: 10, y: [20, 30], z: { a: { b: 42 } } } as const;
|
||||
>x1 : { readonly x: 10; readonly y: readonly [20, 30]; z: { a: { readonly b: 42; }; }; }
|
||||
>{ x: 10, y: [20, 30], z: { a: { b: 42 } } } as const : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
|
||||
>{ x: 10, y: [20, 30], z: { a: { b: 42 } } } : { readonly x: 10; readonly y: readonly [20, 30]; readonly z: { readonly a: { readonly b: 42; }; }; }
|
||||
>x : 10
|
||||
>10 : 10
|
||||
>y : readonly [20, 30]
|
||||
>[20, 30] : readonly [20, 30]
|
||||
>20 : 20
|
||||
>30 : 30
|
||||
>z : { readonly a: { readonly b: 42; }; }
|
||||
>{ a: { b: 42 } } : { readonly a: { readonly b: 42; }; }
|
||||
>a : { readonly b: 42; }
|
||||
>{ b: 42 } : { readonly b: 42; }
|
||||
>b : 42
|
||||
>42 : 42
|
||||
|
||||
let q1 = <const> 10;
|
||||
>q1 : 10
|
||||
><const> 10 : 10
|
||||
>10 : 10
|
||||
|
||||
let q2 = <const> 'abc';
|
||||
>q2 : "abc"
|
||||
><const> 'abc' : "abc"
|
||||
>'abc' : "abc"
|
||||
|
||||
let q3 = <const> true;
|
||||
>q3 : true
|
||||
><const> true : true
|
||||
>true : true
|
||||
|
||||
let q4 = <const> [1, 2, 3];
|
||||
>q4 : readonly [1, 2, 3]
|
||||
><const> [1, 2, 3] : readonly [1, 2, 3]
|
||||
>[1, 2, 3] : readonly [1, 2, 3]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
let q5 = <const> { x: 10, y: 20 };
|
||||
>q5 : { readonly x: 10; readonly y: 20; }
|
||||
><const> { x: 10, y: 20 } : { readonly x: 10; readonly y: 20; }
|
||||
>{ x: 10, y: 20 } : { readonly x: 10; readonly y: 20; }
|
||||
>x : 10
|
||||
>10 : 10
|
||||
>y : 20
|
||||
>20 : 20
|
||||
|
||||
declare function id<T>(x: T): T;
|
||||
>id : <T>(x: T) => T
|
||||
>x : T
|
||||
|
||||
let e1 = v1 as const; // Error
|
||||
>e1 : "abc"
|
||||
>v1 as const : "abc"
|
||||
>v1 : "abc"
|
||||
|
||||
let e2 = (true ? 1 : 0) as const; // Error
|
||||
>e2 : 0 | 1
|
||||
>(true ? 1 : 0) as const : 0 | 1
|
||||
>(true ? 1 : 0) : 0 | 1
|
||||
>true ? 1 : 0 : 0 | 1
|
||||
>true : true
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
let e3 = id(1) as const; // Error
|
||||
>e3 : 1
|
||||
>id(1) as const : 1
|
||||
>id(1) : 1
|
||||
>id : <T>(x: T) => T
|
||||
>1 : 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2503: Cannot find namespace 'module'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,13): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(11,19): error TS1005: ';' expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,35): error TS1005: ')' expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
@@ -105,7 +105,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
|
||||
~~~~~~
|
||||
!!! error TS2503: Cannot find namespace 'module'.
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
|
||||
@@ -93,7 +93,34 @@ let xyz: LikeA | LikeB = {
|
||||
}
|
||||
};
|
||||
|
||||
xyz;
|
||||
xyz;
|
||||
|
||||
// Repro from #29168
|
||||
|
||||
interface TestObject {
|
||||
type?: 'object';
|
||||
items: {
|
||||
[k: string]: TestGeneric;
|
||||
};
|
||||
}
|
||||
|
||||
interface TestString {
|
||||
type: 'string';
|
||||
}
|
||||
|
||||
type TestGeneric = (TestString | TestObject) & { [k: string]: any; };
|
||||
|
||||
const test: TestGeneric = {
|
||||
items: {
|
||||
hello: { type: 'string' },
|
||||
world: {
|
||||
items: {
|
||||
nested: { type: 'string' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [contextualTypeShouldBeLiteral.js]
|
||||
"use strict";
|
||||
@@ -134,3 +161,13 @@ var xyz = {
|
||||
}
|
||||
};
|
||||
xyz;
|
||||
var test = {
|
||||
items: {
|
||||
hello: { type: 'string' },
|
||||
world: {
|
||||
items: {
|
||||
nested: { type: 'string' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -227,3 +227,59 @@ let xyz: LikeA | LikeB = {
|
||||
xyz;
|
||||
>xyz : Symbol(xyz, Decl(contextualTypeShouldBeLiteral.ts, 82, 3))
|
||||
|
||||
// Repro from #29168
|
||||
|
||||
interface TestObject {
|
||||
>TestObject : Symbol(TestObject, Decl(contextualTypeShouldBeLiteral.ts, 94, 4))
|
||||
|
||||
type?: 'object';
|
||||
>type : Symbol(TestObject.type, Decl(contextualTypeShouldBeLiteral.ts, 98, 22))
|
||||
|
||||
items: {
|
||||
>items : Symbol(TestObject.items, Decl(contextualTypeShouldBeLiteral.ts, 99, 18))
|
||||
|
||||
[k: string]: TestGeneric;
|
||||
>k : Symbol(k, Decl(contextualTypeShouldBeLiteral.ts, 101, 5))
|
||||
>TestGeneric : Symbol(TestGeneric, Decl(contextualTypeShouldBeLiteral.ts, 107, 1))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
interface TestString {
|
||||
>TestString : Symbol(TestString, Decl(contextualTypeShouldBeLiteral.ts, 103, 1))
|
||||
|
||||
type: 'string';
|
||||
>type : Symbol(TestString.type, Decl(contextualTypeShouldBeLiteral.ts, 105, 22))
|
||||
}
|
||||
|
||||
type TestGeneric = (TestString | TestObject) & { [k: string]: any; };
|
||||
>TestGeneric : Symbol(TestGeneric, Decl(contextualTypeShouldBeLiteral.ts, 107, 1))
|
||||
>TestString : Symbol(TestString, Decl(contextualTypeShouldBeLiteral.ts, 103, 1))
|
||||
>TestObject : Symbol(TestObject, Decl(contextualTypeShouldBeLiteral.ts, 94, 4))
|
||||
>k : Symbol(k, Decl(contextualTypeShouldBeLiteral.ts, 109, 50))
|
||||
|
||||
const test: TestGeneric = {
|
||||
>test : Symbol(test, Decl(contextualTypeShouldBeLiteral.ts, 111, 5))
|
||||
>TestGeneric : Symbol(TestGeneric, Decl(contextualTypeShouldBeLiteral.ts, 107, 1))
|
||||
|
||||
items: {
|
||||
>items : Symbol(items, Decl(contextualTypeShouldBeLiteral.ts, 111, 27))
|
||||
|
||||
hello: { type: 'string' },
|
||||
>hello : Symbol(hello, Decl(contextualTypeShouldBeLiteral.ts, 112, 10))
|
||||
>type : Symbol(type, Decl(contextualTypeShouldBeLiteral.ts, 113, 12))
|
||||
|
||||
world: {
|
||||
>world : Symbol(world, Decl(contextualTypeShouldBeLiteral.ts, 113, 30))
|
||||
|
||||
items: {
|
||||
>items : Symbol(items, Decl(contextualTypeShouldBeLiteral.ts, 114, 12))
|
||||
|
||||
nested: { type: 'string' }
|
||||
>nested : Symbol(nested, Decl(contextualTypeShouldBeLiteral.ts, 115, 14))
|
||||
>type : Symbol(type, Decl(contextualTypeShouldBeLiteral.ts, 116, 17))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -222,3 +222,59 @@ let xyz: LikeA | LikeB = {
|
||||
xyz;
|
||||
>xyz : LikeA
|
||||
|
||||
// Repro from #29168
|
||||
|
||||
interface TestObject {
|
||||
type?: 'object';
|
||||
>type : "object" | undefined
|
||||
|
||||
items: {
|
||||
>items : { [k: string]: TestGeneric; }
|
||||
|
||||
[k: string]: TestGeneric;
|
||||
>k : string
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
interface TestString {
|
||||
type: 'string';
|
||||
>type : "string"
|
||||
}
|
||||
|
||||
type TestGeneric = (TestString | TestObject) & { [k: string]: any; };
|
||||
>TestGeneric : TestGeneric
|
||||
>k : string
|
||||
|
||||
const test: TestGeneric = {
|
||||
>test : TestGeneric
|
||||
>{ items: { hello: { type: 'string' }, world: { items: { nested: { type: 'string' } } } }} : { items: { hello: { type: "string"; }; world: { items: { nested: { type: "string"; }; }; }; }; }
|
||||
|
||||
items: {
|
||||
>items : { hello: { type: "string"; }; world: { items: { nested: { type: "string"; }; }; }; }
|
||||
>{ hello: { type: 'string' }, world: { items: { nested: { type: 'string' } } } } : { hello: { type: "string"; }; world: { items: { nested: { type: "string"; }; }; }; }
|
||||
|
||||
hello: { type: 'string' },
|
||||
>hello : { type: "string"; }
|
||||
>{ type: 'string' } : { type: "string"; }
|
||||
>type : "string"
|
||||
>'string' : "string"
|
||||
|
||||
world: {
|
||||
>world : { items: { nested: { type: "string"; }; }; }
|
||||
>{ items: { nested: { type: 'string' } } } : { items: { nested: { type: "string"; }; }; }
|
||||
|
||||
items: {
|
||||
>items : { nested: { type: "string"; }; }
|
||||
>{ nested: { type: 'string' } } : { nested: { type: "string"; }; }
|
||||
|
||||
nested: { type: 'string' }
|
||||
>nested : { type: "string"; }
|
||||
>{ type: 'string' } : { type: "string"; }
|
||||
>type : "string"
|
||||
>'string' : "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts(8,29): error TS7031: Binding element 'foo' implicitly has an 'any' type.
|
||||
tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts(14,27): error TS7006: Parameter 'foo' implicitly has an 'any' type.
|
||||
tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts(27,42): error TS7031: Binding element 'foo' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts (3 errors) ====
|
||||
declare function id1<T>(input: T): T;
|
||||
declare function id2<T extends (x: any) => any>(input: T): T;
|
||||
declare function id3<T extends (x: { foo: any }) => any>(input: T): T;
|
||||
declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
|
||||
const f10 = function ({ foo = 42 }) { return foo };
|
||||
const f11 = id1(function ({ foo = 42 }) { return foo }); // Implicit any error
|
||||
~~~
|
||||
!!! error TS7031: Binding element 'foo' implicitly has an 'any' type.
|
||||
const f12 = id2(function ({ foo = 42 }) { return foo });
|
||||
const f13 = id3(function ({ foo = 42 }) { return foo });
|
||||
const f14 = id4(function ({ foo = 42 }) { return foo });
|
||||
|
||||
const f20 = function (foo = 42) { return foo };
|
||||
const f21 = id1(function (foo = 42) { return foo }); // Implicit any error
|
||||
~~~~~~~~
|
||||
!!! error TS7006: Parameter 'foo' implicitly has an 'any' type.
|
||||
const f22 = id2(function (foo = 42) { return foo });
|
||||
const f25 = id5(function (foo = 42) { return foo });
|
||||
|
||||
// Repro from #28816
|
||||
|
||||
function id<T>(input: T): T { return input }
|
||||
|
||||
function getFoo ({ foo = 42 }) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
const newGetFoo = id(getFoo);
|
||||
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
|
||||
~~~
|
||||
!!! error TS7031: Binding element 'foo' implicitly has an 'any' type.
|
||||
return foo;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//// [contextuallyTypedParametersWithInitializers.ts]
|
||||
declare function id1<T>(input: T): T;
|
||||
declare function id2<T extends (x: any) => any>(input: T): T;
|
||||
declare function id3<T extends (x: { foo: any }) => any>(input: T): T;
|
||||
declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
|
||||
const f10 = function ({ foo = 42 }) { return foo };
|
||||
const f11 = id1(function ({ foo = 42 }) { return foo }); // Implicit any error
|
||||
const f12 = id2(function ({ foo = 42 }) { return foo });
|
||||
const f13 = id3(function ({ foo = 42 }) { return foo });
|
||||
const f14 = id4(function ({ foo = 42 }) { return foo });
|
||||
|
||||
const f20 = function (foo = 42) { return foo };
|
||||
const f21 = id1(function (foo = 42) { return foo }); // Implicit any error
|
||||
const f22 = id2(function (foo = 42) { return foo });
|
||||
const f25 = id5(function (foo = 42) { return foo });
|
||||
|
||||
// Repro from #28816
|
||||
|
||||
function id<T>(input: T): T { return input }
|
||||
|
||||
function getFoo ({ foo = 42 }) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
const newGetFoo = id(getFoo);
|
||||
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
|
||||
return foo;
|
||||
});
|
||||
|
||||
|
||||
//// [contextuallyTypedParametersWithInitializers.js]
|
||||
"use strict";
|
||||
var f10 = function (_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
};
|
||||
var f11 = id1(function (_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
}); // Implicit any error
|
||||
var f12 = id2(function (_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
});
|
||||
var f13 = id3(function (_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
});
|
||||
var f14 = id4(function (_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
});
|
||||
var f20 = function (foo) {
|
||||
if (foo === void 0) { foo = 42; }
|
||||
return foo;
|
||||
};
|
||||
var f21 = id1(function (foo) {
|
||||
if (foo === void 0) { foo = 42; }
|
||||
return foo;
|
||||
}); // Implicit any error
|
||||
var f22 = id2(function (foo) {
|
||||
if (foo === void 0) { foo = 42; }
|
||||
return foo;
|
||||
});
|
||||
var f25 = id5(function (foo) {
|
||||
if (foo === void 0) { foo = 42; }
|
||||
return foo;
|
||||
});
|
||||
// Repro from #28816
|
||||
function id(input) { return input; }
|
||||
function getFoo(_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
}
|
||||
var newGetFoo = id(getFoo);
|
||||
var newGetFoo2 = id(function getFoo(_a) {
|
||||
var _b = _a.foo, foo = _b === void 0 ? 42 : _b;
|
||||
return foo;
|
||||
});
|
||||
|
||||
|
||||
//// [contextuallyTypedParametersWithInitializers.d.ts]
|
||||
declare function id1<T>(input: T): T;
|
||||
declare function id2<T extends (x: any) => any>(input: T): T;
|
||||
declare function id3<T extends (x: {
|
||||
foo: any;
|
||||
}) => any>(input: T): T;
|
||||
declare function id4<T extends (x: {
|
||||
foo?: number;
|
||||
}) => any>(input: T): T;
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
declare const f10: ({ foo }: {
|
||||
foo?: number | undefined;
|
||||
}) => number;
|
||||
declare const f11: ({ foo }: any) => any;
|
||||
declare const f12: ({ foo }: any) => any;
|
||||
declare const f13: ({ foo }: {
|
||||
foo: any;
|
||||
}) => any;
|
||||
declare const f14: ({ foo }: {
|
||||
foo?: number | undefined;
|
||||
}) => number;
|
||||
declare const f20: (foo?: number) => number;
|
||||
declare const f21: (foo?: any) => any;
|
||||
declare const f22: (foo?: any) => any;
|
||||
declare const f25: (foo?: number | undefined) => number;
|
||||
declare function id<T>(input: T): T;
|
||||
declare function getFoo({ foo }: {
|
||||
foo?: number | undefined;
|
||||
}): number;
|
||||
declare const newGetFoo: typeof getFoo;
|
||||
declare const newGetFoo2: ({ foo }: any) => any;
|
||||
@@ -0,0 +1,128 @@
|
||||
=== tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts ===
|
||||
declare function id1<T>(input: T): T;
|
||||
>id1 : Symbol(id1, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 21))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 24))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 21))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 21))
|
||||
|
||||
declare function id2<T extends (x: any) => any>(input: T): T;
|
||||
>id2 : Symbol(id2, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 37))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 21))
|
||||
>x : Symbol(x, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 32))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 48))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 21))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 21))
|
||||
|
||||
declare function id3<T extends (x: { foo: any }) => any>(input: T): T;
|
||||
>id3 : Symbol(id3, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 61))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 21))
|
||||
>x : Symbol(x, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 32))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 36))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 57))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 21))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 21))
|
||||
|
||||
declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
|
||||
>id4 : Symbol(id4, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 70))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 21))
|
||||
>x : Symbol(x, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 32))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 36))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 61))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 21))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 21))
|
||||
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
>id5 : Symbol(id5, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 74))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 4, 21))
|
||||
>x : Symbol(x, Decl(contextuallyTypedParametersWithInitializers.ts, 4, 32))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 4, 52))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 4, 21))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 4, 21))
|
||||
|
||||
const f10 = function ({ foo = 42 }) { return foo };
|
||||
>f10 : Symbol(f10, Decl(contextuallyTypedParametersWithInitializers.ts, 6, 5))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 6, 23))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 6, 23))
|
||||
|
||||
const f11 = id1(function ({ foo = 42 }) { return foo }); // Implicit any error
|
||||
>f11 : Symbol(f11, Decl(contextuallyTypedParametersWithInitializers.ts, 7, 5))
|
||||
>id1 : Symbol(id1, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 7, 27))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 7, 27))
|
||||
|
||||
const f12 = id2(function ({ foo = 42 }) { return foo });
|
||||
>f12 : Symbol(f12, Decl(contextuallyTypedParametersWithInitializers.ts, 8, 5))
|
||||
>id2 : Symbol(id2, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 37))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 8, 27))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 8, 27))
|
||||
|
||||
const f13 = id3(function ({ foo = 42 }) { return foo });
|
||||
>f13 : Symbol(f13, Decl(contextuallyTypedParametersWithInitializers.ts, 9, 5))
|
||||
>id3 : Symbol(id3, Decl(contextuallyTypedParametersWithInitializers.ts, 1, 61))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 9, 27))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 9, 27))
|
||||
|
||||
const f14 = id4(function ({ foo = 42 }) { return foo });
|
||||
>f14 : Symbol(f14, Decl(contextuallyTypedParametersWithInitializers.ts, 10, 5))
|
||||
>id4 : Symbol(id4, Decl(contextuallyTypedParametersWithInitializers.ts, 2, 70))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 10, 27))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 10, 27))
|
||||
|
||||
const f20 = function (foo = 42) { return foo };
|
||||
>f20 : Symbol(f20, Decl(contextuallyTypedParametersWithInitializers.ts, 12, 5))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 12, 22))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 12, 22))
|
||||
|
||||
const f21 = id1(function (foo = 42) { return foo }); // Implicit any error
|
||||
>f21 : Symbol(f21, Decl(contextuallyTypedParametersWithInitializers.ts, 13, 5))
|
||||
>id1 : Symbol(id1, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 13, 26))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 13, 26))
|
||||
|
||||
const f22 = id2(function (foo = 42) { return foo });
|
||||
>f22 : Symbol(f22, Decl(contextuallyTypedParametersWithInitializers.ts, 14, 5))
|
||||
>id2 : Symbol(id2, Decl(contextuallyTypedParametersWithInitializers.ts, 0, 37))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 14, 26))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 14, 26))
|
||||
|
||||
const f25 = id5(function (foo = 42) { return foo });
|
||||
>f25 : Symbol(f25, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 5))
|
||||
>id5 : Symbol(id5, Decl(contextuallyTypedParametersWithInitializers.ts, 3, 74))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 26))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 26))
|
||||
|
||||
// Repro from #28816
|
||||
|
||||
function id<T>(input: T): T { return input }
|
||||
>id : Symbol(id, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 52))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 12))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 15))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 12))
|
||||
>T : Symbol(T, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 12))
|
||||
>input : Symbol(input, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 15))
|
||||
|
||||
function getFoo ({ foo = 42 }) {
|
||||
>getFoo : Symbol(getFoo, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 44))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 21, 18))
|
||||
|
||||
return foo;
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 21, 18))
|
||||
}
|
||||
|
||||
const newGetFoo = id(getFoo);
|
||||
>newGetFoo : Symbol(newGetFoo, Decl(contextuallyTypedParametersWithInitializers.ts, 25, 5))
|
||||
>id : Symbol(id, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 52))
|
||||
>getFoo : Symbol(getFoo, Decl(contextuallyTypedParametersWithInitializers.ts, 19, 44))
|
||||
|
||||
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
|
||||
>newGetFoo2 : Symbol(newGetFoo2, Decl(contextuallyTypedParametersWithInitializers.ts, 26, 5))
|
||||
>id : Symbol(id, Decl(contextuallyTypedParametersWithInitializers.ts, 15, 52))
|
||||
>getFoo : Symbol(getFoo, Decl(contextuallyTypedParametersWithInitializers.ts, 26, 22))
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 26, 40))
|
||||
|
||||
return foo;
|
||||
>foo : Symbol(foo, Decl(contextuallyTypedParametersWithInitializers.ts, 26, 40))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
=== tests/cases/compiler/contextuallyTypedParametersWithInitializers.ts ===
|
||||
declare function id1<T>(input: T): T;
|
||||
>id1 : <T>(input: T) => T
|
||||
>input : T
|
||||
|
||||
declare function id2<T extends (x: any) => any>(input: T): T;
|
||||
>id2 : <T extends (x: any) => any>(input: T) => T
|
||||
>x : any
|
||||
>input : T
|
||||
|
||||
declare function id3<T extends (x: { foo: any }) => any>(input: T): T;
|
||||
>id3 : <T extends (x: { foo: any; }) => any>(input: T) => T
|
||||
>x : { foo: any; }
|
||||
>foo : any
|
||||
>input : T
|
||||
|
||||
declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
|
||||
>id4 : <T extends (x: { foo?: number | undefined; }) => any>(input: T) => T
|
||||
>x : { foo?: number | undefined; }
|
||||
>foo : number | undefined
|
||||
>input : T
|
||||
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
>id5 : <T extends (x?: number | undefined) => any>(input: T) => T
|
||||
>x : number | undefined
|
||||
>input : T
|
||||
|
||||
const f10 = function ({ foo = 42 }) { return foo };
|
||||
>f10 : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>function ({ foo = 42 }) { return foo } : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>foo : number
|
||||
>42 : 42
|
||||
>foo : number
|
||||
|
||||
const f11 = id1(function ({ foo = 42 }) { return foo }); // Implicit any error
|
||||
>f11 : ({ foo }: any) => any
|
||||
>id1(function ({ foo = 42 }) { return foo }) : ({ foo }: any) => any
|
||||
>id1 : <T>(input: T) => T
|
||||
>function ({ foo = 42 }) { return foo } : ({ foo }: any) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
>foo : any
|
||||
|
||||
const f12 = id2(function ({ foo = 42 }) { return foo });
|
||||
>f12 : ({ foo }: any) => any
|
||||
>id2(function ({ foo = 42 }) { return foo }) : ({ foo }: any) => any
|
||||
>id2 : <T extends (x: any) => any>(input: T) => T
|
||||
>function ({ foo = 42 }) { return foo } : ({ foo }: any) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
>foo : any
|
||||
|
||||
const f13 = id3(function ({ foo = 42 }) { return foo });
|
||||
>f13 : ({ foo }: { foo: any; }) => any
|
||||
>id3(function ({ foo = 42 }) { return foo }) : ({ foo }: { foo: any; }) => any
|
||||
>id3 : <T extends (x: { foo: any; }) => any>(input: T) => T
|
||||
>function ({ foo = 42 }) { return foo } : ({ foo }: { foo: any; }) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
>foo : any
|
||||
|
||||
const f14 = id4(function ({ foo = 42 }) { return foo });
|
||||
>f14 : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>id4(function ({ foo = 42 }) { return foo }) : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>id4 : <T extends (x: { foo?: number | undefined; }) => any>(input: T) => T
|
||||
>function ({ foo = 42 }) { return foo } : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>foo : number
|
||||
>42 : 42
|
||||
>foo : number
|
||||
|
||||
const f20 = function (foo = 42) { return foo };
|
||||
>f20 : (foo?: number) => number
|
||||
>function (foo = 42) { return foo } : (foo?: number) => number
|
||||
>foo : number
|
||||
>42 : 42
|
||||
>foo : number
|
||||
|
||||
const f21 = id1(function (foo = 42) { return foo }); // Implicit any error
|
||||
>f21 : (foo?: any) => any
|
||||
>id1(function (foo = 42) { return foo }) : (foo?: any) => any
|
||||
>id1 : <T>(input: T) => T
|
||||
>function (foo = 42) { return foo } : (foo?: any) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
>foo : any
|
||||
|
||||
const f22 = id2(function (foo = 42) { return foo });
|
||||
>f22 : (foo?: any) => any
|
||||
>id2(function (foo = 42) { return foo }) : (foo?: any) => any
|
||||
>id2 : <T extends (x: any) => any>(input: T) => T
|
||||
>function (foo = 42) { return foo } : (foo?: any) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
>foo : any
|
||||
|
||||
const f25 = id5(function (foo = 42) { return foo });
|
||||
>f25 : (foo?: number | undefined) => number
|
||||
>id5(function (foo = 42) { return foo }) : (foo?: number | undefined) => number
|
||||
>id5 : <T extends (x?: number | undefined) => any>(input: T) => T
|
||||
>function (foo = 42) { return foo } : (foo?: number | undefined) => number
|
||||
>foo : number | undefined
|
||||
>42 : 42
|
||||
>foo : number
|
||||
|
||||
// Repro from #28816
|
||||
|
||||
function id<T>(input: T): T { return input }
|
||||
>id : <T>(input: T) => T
|
||||
>input : T
|
||||
>input : T
|
||||
|
||||
function getFoo ({ foo = 42 }) {
|
||||
>getFoo : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>foo : number
|
||||
>42 : 42
|
||||
|
||||
return foo;
|
||||
>foo : number
|
||||
}
|
||||
|
||||
const newGetFoo = id(getFoo);
|
||||
>newGetFoo : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>id(getFoo) : ({ foo }: { foo?: number | undefined; }) => number
|
||||
>id : <T>(input: T) => T
|
||||
>getFoo : ({ foo }: { foo?: number | undefined; }) => number
|
||||
|
||||
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
|
||||
>newGetFoo2 : ({ foo }: any) => any
|
||||
>id(function getFoo ({ foo = 42 }) { return foo;}) : ({ foo }: any) => any
|
||||
>id : <T>(input: T) => T
|
||||
>function getFoo ({ foo = 42 }) { return foo;} : ({ foo }: any) => any
|
||||
>getFoo : ({ foo }: any) => any
|
||||
>foo : any
|
||||
>42 : 42
|
||||
|
||||
return foo;
|
||||
>foo : any
|
||||
|
||||
});
|
||||
|
||||
@@ -101,9 +101,9 @@ function c<T>(data: string | T): T {
|
||||
|
||||
return JSON.parse(data);
|
||||
>JSON.parse(data) : any
|
||||
>JSON.parse : (text: string, reviver?: (key: any, value: any) => any) => any
|
||||
>JSON.parse : (text: string, reviver?: (this: any, key: string, value: any) => any) => any
|
||||
>JSON : JSON
|
||||
>parse : (text: string, reviver?: (key: any, value: any) => any) => any
|
||||
>parse : (text: string, reviver?: (this: any, key: string, value: any) => any) => any
|
||||
>data : string | (T & string)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -316,9 +316,9 @@ export class HTMLtoJSX {
|
||||
>'{' + JSON.stringify(whitespace) : string
|
||||
>'{' : "{"
|
||||
>JSON.stringify(whitespace) : string
|
||||
>JSON.stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
|
||||
>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
|
||||
>JSON : JSON
|
||||
>stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
|
||||
>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; }
|
||||
>whitespace : string
|
||||
>'}' : "}"
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ const Child: SFC<Props> = ({
|
||||
>`name: ${name} props: ${JSON.stringify(props)}` : string
|
||||
>name : "Apollo" | "Artemis" | "Dionysus" | "Persephone"
|
||||
>JSON.stringify(props) : string
|
||||
>JSON.stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
|
||||
>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
|
||||
>JSON : JSON
|
||||
>stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
|
||||
>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
|
||||
>props : {}
|
||||
|
||||
// Repro from #29189
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(1,1): error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(2,5): error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(3,19): error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(7,1): error TS2582: Cannot find name 'suite'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(8,5): error TS2582: Cannot find name 'test'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(1,1): error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(2,5): error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(3,19): error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(7,1): error TS2582: Cannot find name 'suite'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(8,5): error TS2582: Cannot find name 'test'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(9,9): error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(9,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(9,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(10,9): error TS2584: Cannot find name 'document'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(12,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(13,19): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(14,19): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(12,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(13,19): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(14,19): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(16,23): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(17,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/didYouMeanSuggestionErrors.ts(18,23): error TS2583: Cannot find name 'WeakMap'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
@@ -22,40 +22,40 @@ tests/cases/compiler/didYouMeanSuggestionErrors.ts(24,18): error TS2583: Cannot
|
||||
==== tests/cases/compiler/didYouMeanSuggestionErrors.ts (19 errors) ====
|
||||
describe("my test suite", () => {
|
||||
~~~~~~~~
|
||||
!!! error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
!!! error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
it("should run", () => {
|
||||
~~
|
||||
!!! error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
!!! error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
const a = $(".thing");
|
||||
~
|
||||
!!! error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig.
|
||||
!!! error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`.
|
||||
});
|
||||
});
|
||||
|
||||
suite("another suite", () => {
|
||||
~~~~~
|
||||
!!! error TS2582: Cannot find name 'suite'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
!!! error TS2582: Cannot find name 'suite'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
test("everything else", () => {
|
||||
~~~~
|
||||
!!! error TS2582: Cannot find name 'test'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
|
||||
!!! error TS2582: Cannot find name 'test'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
|
||||
console.log(process.env);
|
||||
~~~~~~~
|
||||
!!! error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.
|
||||
~~~~~~~
|
||||
!!! error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
document.createElement("div");
|
||||
~~~~~~~~
|
||||
!!! error TS2584: Cannot find name 'document'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.
|
||||
|
||||
const x = require("fs");
|
||||
~~~~~~~
|
||||
!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
const y = Buffer.from([]);
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
const z = module.exports;
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
|
||||
const a = new Map();
|
||||
~~~
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/compiler/doNotInferUnrelatedTypes.ts ===
|
||||
// #16709
|
||||
declare function dearray<T>(ara: ReadonlyArray<T>): T;
|
||||
>dearray : <T>(ara: ReadonlyArray<T>) => T
|
||||
>ara : ReadonlyArray<T>
|
||||
>dearray : <T>(ara: readonly T[]) => T
|
||||
>ara : readonly T[]
|
||||
|
||||
type LiteralType = "foo" | "bar";
|
||||
>LiteralType : LiteralType
|
||||
@@ -13,6 +13,6 @@ declare var alt: Array<LiteralType>;
|
||||
let foo: LiteralType = dearray(alt);
|
||||
>foo : LiteralType
|
||||
>dearray(alt) : LiteralType
|
||||
>dearray : <T>(ara: ReadonlyArray<T>) => T
|
||||
>dearray : <T>(ara: readonly T[]) => T
|
||||
>alt : LiteralType[]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/errorMessagesIntersectionTypes02.ts(14,5): error TS2322: Type '{ fooProp: string; } & Bar' is not assignable to type 'FooBar'.
|
||||
tests/cases/compiler/errorMessagesIntersectionTypes02.ts(14,5): error TS2322: Type '{ fooProp: "frizzlebizzle"; } & Bar' is not assignable to type 'FooBar'.
|
||||
Types of property 'fooProp' are incompatible.
|
||||
Type 'string' is not assignable to type '"hello" | "world"'.
|
||||
Type '"frizzlebizzle"' is not assignable to type '"hello" | "world"'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorMessagesIntersectionTypes02.ts (1 errors) ====
|
||||
@@ -19,8 +19,8 @@ tests/cases/compiler/errorMessagesIntersectionTypes02.ts(14,5): error TS2322: Ty
|
||||
|
||||
let fooBar: FooBar = mixBar({
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '{ fooProp: string; } & Bar' is not assignable to type 'FooBar'.
|
||||
!!! error TS2322: Type '{ fooProp: "frizzlebizzle"; } & Bar' is not assignable to type 'FooBar'.
|
||||
!!! error TS2322: Types of property 'fooProp' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '"hello" | "world"'.
|
||||
!!! error TS2322: Type '"frizzlebizzle"' is not assignable to type '"hello" | "world"'.
|
||||
fooProp: "frizzlebizzle"
|
||||
});
|
||||
@@ -18,12 +18,12 @@ declare function mixBar<T>(obj: T): T & Bar;
|
||||
|
||||
let fooBar: FooBar = mixBar({
|
||||
>fooBar : FooBar
|
||||
>mixBar({ fooProp: "frizzlebizzle"}) : { fooProp: string; } & Bar
|
||||
>mixBar({ fooProp: "frizzlebizzle"}) : { fooProp: "frizzlebizzle"; } & Bar
|
||||
>mixBar : <T>(obj: T) => T & Bar
|
||||
>{ fooProp: "frizzlebizzle"} : { fooProp: string; }
|
||||
>{ fooProp: "frizzlebizzle"} : { fooProp: "frizzlebizzle"; }
|
||||
|
||||
fooProp: "frizzlebizzle"
|
||||
>fooProp : string
|
||||
>fooProp : "frizzlebizzle"
|
||||
>"frizzlebizzle" : "frizzlebizzle"
|
||||
|
||||
});
|
||||
@@ -31,9 +31,9 @@ class C {
|
||||
const nodes = document.getElementsByTagName("li");
|
||||
>nodes : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName("li") : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document : Document
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>"li" : "li"
|
||||
|
||||
type ItemType = "".typeof(nodes.item(0));
|
||||
@@ -72,9 +72,9 @@ class C2 {
|
||||
const nodes2 = document.getElementsByTagName("li");
|
||||
>nodes2 : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName("li") : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document : Document
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>"li" : "li"
|
||||
|
||||
type ItemType2 = 4..typeof(nodes.item(0));
|
||||
@@ -114,9 +114,9 @@ class C3 {
|
||||
const nodes3 = document.getElementsByTagName("li");
|
||||
>nodes3 : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName("li") : HTMLCollectionOf<HTMLLIElement>
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document.getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>document : Document
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>getElementsByTagName : { <K extends "object" | "li" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr">(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>; <K extends "symbol" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>; (qualifiedName: string): HTMLCollectionOf<Element>; }
|
||||
>"li" : "li"
|
||||
|
||||
type ItemType3 = true.typeof(nodes.item(0));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/externModule.ts(1,1): error TS2304: Cannot find name 'declare'.
|
||||
tests/cases/compiler/externModule.ts(1,9): error TS1005: ';' expected.
|
||||
tests/cases/compiler/externModule.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/externModule.ts(1,9): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/externModule.ts(1,16): error TS1005: ';' expected.
|
||||
tests/cases/compiler/externModule.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/externModule.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
@@ -21,7 +21,7 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat
|
||||
~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
export class XDate {
|
||||
|
||||
@@ -25,10 +25,10 @@ foo((x?)=>{return x;})
|
||||
foo((x=0)=>{return x;})
|
||||
>foo((x=0)=>{return x;}) : any
|
||||
>foo : any
|
||||
>(x=0)=>{return x;} : (x?: number) => number
|
||||
>x : number
|
||||
>(x=0)=>{return x;} : (x?: any) => any
|
||||
>x : any
|
||||
>0 : 0
|
||||
>x : number
|
||||
>x : any
|
||||
|
||||
var y = x:number => x*x;
|
||||
>y : any
|
||||
|
||||
@@ -653,8 +653,8 @@ foo(
|
||||
>116 : 116
|
||||
|
||||
(a = 0) => 117,
|
||||
>(a = 0) => 117 : (a?: number) => number
|
||||
>a : number
|
||||
>(a = 0) => 117 : (a?: any) => number
|
||||
>a : any
|
||||
>0 : 0
|
||||
>117 : 117
|
||||
|
||||
@@ -670,9 +670,9 @@ foo(
|
||||
>119 : 119
|
||||
|
||||
(a, b? = 0, ...c: number[]) => 120,
|
||||
>(a, b? = 0, ...c: number[]) => 120 : (a: any, b?: number, ...c: number[]) => number
|
||||
>(a, b? = 0, ...c: number[]) => 120 : (a: any, b?: any, ...c: number[]) => number
|
||||
>a : any
|
||||
>b : number
|
||||
>b : any
|
||||
>0 : 0
|
||||
>c : number[]
|
||||
>120 : 120
|
||||
|
||||
@@ -88,8 +88,8 @@
|
||||
>116 : 116
|
||||
|
||||
(a = 0) => 117,
|
||||
>(a = 0) => 117 : (a?: number) => number
|
||||
>a : number
|
||||
>(a = 0) => 117 : (a?: any) => number
|
||||
>a : any
|
||||
>0 : 0
|
||||
>117 : 117
|
||||
|
||||
@@ -105,9 +105,9 @@
|
||||
>119 : 119
|
||||
|
||||
(a, b? = 0, ...c: number[]) => 120,
|
||||
>(a, b? = 0, ...c: number[]) => 120 : (a: any, b?: number, ...c: number[]) => number
|
||||
>(a, b? = 0, ...c: number[]) => 120 : (a: any, b?: any, ...c: number[]) => number
|
||||
>a : any
|
||||
>b : number
|
||||
>b : any
|
||||
>0 : 0
|
||||
>c : number[]
|
||||
>120 : 120
|
||||
|
||||
@@ -50,9 +50,9 @@ tests/cases/conformance/fixSignatureCaching.ts(915,36): error TS2339: Property '
|
||||
tests/cases/conformance/fixSignatureCaching.ts(915,53): error TS2339: Property 'mobileDetectRules' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(955,42): error TS2339: Property 'mobileGrade' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(964,57): error TS2339: Property 'getDeviceSmallerSide' does not exist on type '{}'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,16): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,42): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(979,37): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,16): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(978,42): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(979,37): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(980,23): error TS2304: Cannot find name 'define'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(980,48): error TS2304: Cannot find name 'define'.
|
||||
tests/cases/conformance/fixSignatureCaching.ts(981,16): error TS2304: Cannot find name 'define'.
|
||||
@@ -1143,12 +1143,12 @@ tests/cases/conformance/fixSignatureCaching.ts(983,44): error TS2339: Property '
|
||||
})((function (undefined) {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
return function (factory) { module.exports = factory(); };
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'define'.
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(9,9): error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(10,9): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(10,17): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(11,9): error TS2585: 'Map' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(12,9): error TS2585: 'WeakMap' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(13,9): error TS2585: 'Set' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
tests/cases/compiler/forwardDeclaredCommonTypes01.ts(14,9): error TS2585: 'WeakSet' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
|
||||
|
||||
==== tests/cases/compiler/forwardDeclaredCommonTypes01.ts (7 errors) ====
|
||||
interface Promise<T> {}
|
||||
interface Symbol {}
|
||||
interface Map<K, V> {}
|
||||
interface WeakMap<K extends object, V> {}
|
||||
interface Set<T> {}
|
||||
interface WeakSet<T extends object> {}
|
||||
|
||||
(function() {
|
||||
new Promise;
|
||||
~~~~~~~
|
||||
!!! error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
new Symbol; Symbol();
|
||||
~~~~~~
|
||||
!!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
~~~~~~
|
||||
!!! error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
new Map;
|
||||
~~~
|
||||
!!! error TS2585: 'Map' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
new WeakMap;
|
||||
~~~~~~~
|
||||
!!! error TS2585: 'WeakMap' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
new Set;
|
||||
~~~
|
||||
!!! error TS2585: 'Set' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
new WeakSet;
|
||||
~~~~~~~
|
||||
!!! error TS2585: 'WeakSet' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [forwardDeclaredCommonTypes01.ts]
|
||||
interface Promise<T> {}
|
||||
interface Symbol {}
|
||||
interface Map<K, V> {}
|
||||
interface WeakMap<K extends object, V> {}
|
||||
interface Set<T> {}
|
||||
interface WeakSet<T extends object> {}
|
||||
|
||||
(function() {
|
||||
new Promise;
|
||||
new Symbol; Symbol();
|
||||
new Map;
|
||||
new WeakMap;
|
||||
new Set;
|
||||
new WeakSet;
|
||||
});
|
||||
|
||||
|
||||
//// [forwardDeclaredCommonTypes01.js]
|
||||
(function () {
|
||||
new Promise;
|
||||
new Symbol;
|
||||
Symbol();
|
||||
new Map;
|
||||
new WeakMap;
|
||||
new Set;
|
||||
new WeakSet;
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/forwardDeclaredCommonTypes01.ts ===
|
||||
interface Promise<T> {}
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(forwardDeclaredCommonTypes01.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(lib.es5.d.ts, --, --), Decl(forwardDeclaredCommonTypes01.ts, 0, 18))
|
||||
|
||||
interface Symbol {}
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(forwardDeclaredCommonTypes01.ts, 0, 23))
|
||||
|
||||
interface Map<K, V> {}
|
||||
>Map : Symbol(Map, Decl(forwardDeclaredCommonTypes01.ts, 1, 19))
|
||||
>K : Symbol(K, Decl(forwardDeclaredCommonTypes01.ts, 2, 14))
|
||||
>V : Symbol(V, Decl(forwardDeclaredCommonTypes01.ts, 2, 16))
|
||||
|
||||
interface WeakMap<K extends object, V> {}
|
||||
>WeakMap : Symbol(WeakMap, Decl(forwardDeclaredCommonTypes01.ts, 2, 22))
|
||||
>K : Symbol(K, Decl(forwardDeclaredCommonTypes01.ts, 3, 18))
|
||||
>V : Symbol(V, Decl(forwardDeclaredCommonTypes01.ts, 3, 35))
|
||||
|
||||
interface Set<T> {}
|
||||
>Set : Symbol(Set, Decl(forwardDeclaredCommonTypes01.ts, 3, 41))
|
||||
>T : Symbol(T, Decl(forwardDeclaredCommonTypes01.ts, 4, 14))
|
||||
|
||||
interface WeakSet<T extends object> {}
|
||||
>WeakSet : Symbol(WeakSet, Decl(forwardDeclaredCommonTypes01.ts, 4, 19))
|
||||
>T : Symbol(T, Decl(forwardDeclaredCommonTypes01.ts, 5, 18))
|
||||
|
||||
(function() {
|
||||
new Promise;
|
||||
new Symbol; Symbol();
|
||||
new Map;
|
||||
new WeakMap;
|
||||
new Set;
|
||||
new WeakSet;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/forwardDeclaredCommonTypes01.ts ===
|
||||
interface Promise<T> {}
|
||||
interface Symbol {}
|
||||
interface Map<K, V> {}
|
||||
interface WeakMap<K extends object, V> {}
|
||||
interface Set<T> {}
|
||||
interface WeakSet<T extends object> {}
|
||||
|
||||
(function() {
|
||||
>(function() { new Promise; new Symbol; Symbol(); new Map; new WeakMap; new Set; new WeakSet;}) : () => void
|
||||
>function() { new Promise; new Symbol; Symbol(); new Map; new WeakMap; new Set; new WeakSet;} : () => void
|
||||
|
||||
new Promise;
|
||||
>new Promise : any
|
||||
>Promise : any
|
||||
|
||||
new Symbol; Symbol();
|
||||
>new Symbol : any
|
||||
>Symbol : any
|
||||
>Symbol() : any
|
||||
>Symbol : any
|
||||
|
||||
new Map;
|
||||
>new Map : any
|
||||
>Map : any
|
||||
|
||||
new WeakMap;
|
||||
>new WeakMap : any
|
||||
>WeakMap : any
|
||||
|
||||
new Set;
|
||||
>new Set : any
|
||||
>Set : any
|
||||
|
||||
new WeakSet;
|
||||
>new WeakSet : any
|
||||
>WeakSet : any
|
||||
|
||||
});
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
tests/cases/conformance/types/rest/genericRestParameters1.ts(22,1): error TS2556: Expected 3 arguments, but got 1 or more.
|
||||
tests/cases/conformance/types/rest/genericRestParameters1.ts(31,1): error TS2556: Expected 3 arguments, but got 1 or more.
|
||||
tests/cases/conformance/types/rest/genericRestParameters1.ts(133,40): error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
Types of parameters 'args' and 'args' are incompatible.
|
||||
Type 'any[]' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/rest/genericRestParameters1.ts(134,51): error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
Types of parameters 'args' and 'args' are incompatible.
|
||||
Type 'any[]' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/rest/genericRestParameters1.ts(135,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/rest/genericRestParameters1.ts(135,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/rest/genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'.
|
||||
Types of parameters 'a' and 'args' are incompatible.
|
||||
Type 'any' is not assignable to type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/rest/genericRestParameters1.ts (6 errors) ====
|
||||
==== tests/cases/conformance/types/rest/genericRestParameters1.ts (4 errors) ====
|
||||
declare let f1: (...x: [number, string, boolean]) => void;
|
||||
declare let f2: (x0: number, x1: string, x2: boolean) => void;
|
||||
|
||||
@@ -152,19 +146,11 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS232
|
||||
type T05<T> = Parameters<(...args: T[]) => void>;
|
||||
type T06<T> = ConstructorParameters<new (...args: []) => void>;
|
||||
type T07<T extends any[]> = Parameters<(...args: T) => void>;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
!!! error TS2344: Types of parameters 'args' and 'args' are incompatible.
|
||||
!!! error TS2344: Type 'any[]' is not assignable to type 'T'.
|
||||
type T08<T extends any[]> = ConstructorParameters<new (...args: T) => void>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
!!! error TS2344: Types of parameters 'args' and 'args' are incompatible.
|
||||
!!! error TS2344: Type 'any[]' is not assignable to type 'T'.
|
||||
type T09 = Parameters<Function>;
|
||||
~~~~~~~~
|
||||
!!! 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'.
|
||||
!!! 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 Record1 = {
|
||||
move: [number, 'left' | 'right'];
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
Types of parameters 'x' and 'args' are incompatible.
|
||||
Property '0' is missing in type 'any[]' but required in type '[string, ...any[]]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/rest/genericRestParameters2.ts (1 errors) ====
|
||||
declare const t1: [number, string, ...boolean[]];
|
||||
declare const t2: [string, ...boolean[]];
|
||||
declare const t3: [...boolean[]];
|
||||
declare const t4: [];
|
||||
|
||||
declare let f00: (...x: [number, string, boolean]) => void;
|
||||
declare let f01: (a: number, ...x: [string, boolean]) => void;
|
||||
declare let f02: (a: number, b: string, ...x: [boolean]) => void;
|
||||
declare let f03: (a: number, b: string, c: boolean) => void;
|
||||
declare let f04: (a: number, b: string, c: boolean, ...x: []) => void;
|
||||
|
||||
declare let f10: (...x: [number, string, ...boolean[]]) => void;
|
||||
declare let f11: (a: number, ...x: [string, ...boolean[]]) => void;
|
||||
declare let f12: (a: number, b: string, ...x: [...boolean[]]) => void;
|
||||
declare let f13: (a: number, b: string, ...c: boolean[]) => void;
|
||||
|
||||
declare const ns: [number, string];
|
||||
declare const sn: [string, number];
|
||||
|
||||
f10(42, "hello");
|
||||
f10(42, "hello", true);
|
||||
f10(42, "hello", true, false);
|
||||
f10(t1[0], t1[1], t1[2], t1[3]);
|
||||
f10(...t1);
|
||||
f10(42, ...t2);
|
||||
f10(42, "hello", ...t3);
|
||||
f10(42, "hello", true, ...t4);
|
||||
f10(42, "hello", true, ...t4, false, ...t3);
|
||||
|
||||
f11(42, "hello");
|
||||
f11(42, "hello", true);
|
||||
f11(42, "hello", true, false);
|
||||
f11(t1[0], t1[1], t1[2], t1[3]);
|
||||
f11(...t1);
|
||||
f11(42, ...t2);
|
||||
f11(42, "hello", ...t3);
|
||||
f11(42, "hello", true, ...t4);
|
||||
f11(42, "hello", true, ...t4, false, ...t3);
|
||||
|
||||
f12(42, "hello");
|
||||
f12(42, "hello", true);
|
||||
f12(42, "hello", true, false);
|
||||
f12(t1[0], t1[1], t1[2], t1[3]);
|
||||
f12(...t1);
|
||||
f12(42, ...t2);
|
||||
f12(42, "hello", ...t3);
|
||||
f12(42, "hello", true, ...t4);
|
||||
f12(42, "hello", true, ...t4, false, ...t3);
|
||||
|
||||
f13(42, "hello");
|
||||
f13(42, "hello", true);
|
||||
f13(42, "hello", true, false);
|
||||
f13(t1[0], t1[1], t1[2], t1[3]);
|
||||
f13(...t1);
|
||||
f13(42, ...t2);
|
||||
f13(42, "hello", ...t3);
|
||||
f13(42, "hello", true, ...t4);
|
||||
f13(42, "hello", true, ...t4, false, ...t3);
|
||||
|
||||
declare const f20: <T extends unknown[]>(...args: T) => T;
|
||||
|
||||
f20(...t1);
|
||||
f20(42, ...t2);
|
||||
f20(42, "hello", ...t3);
|
||||
f20(42, "hello", ...t2, true);
|
||||
|
||||
type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>;
|
||||
type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>;
|
||||
type T03 = ConstructorParameters<new (x: number, y: string, ...z: boolean[]) => void>;
|
||||
type T04 = ConstructorParameters<new (...args: [number, string, ...boolean[]]) => void>;
|
||||
type T05<T extends any[]> = Parameters<(x: string, ...args: T) => void>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
!!! error TS2344: Types of parameters 'x' and 'args' are incompatible.
|
||||
!!! error TS2344: Property '0' is missing in type 'any[]' but required in type '[string, ...any[]]'.
|
||||
type T06 = T05<[number, ...boolean[]]>;
|
||||
|
||||
type P1<T extends Function> = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[];
|
||||
|
||||
type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>;
|
||||
type T11 = P1<(...z: number[]) => void>;
|
||||
type T12 = P1<(x: number, y: number) => void>;
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(28,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"bar"'.
|
||||
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(175,47): error TS2322: Type 'boolean' is not assignable to type 'true'.
|
||||
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(180,26): error TS2322: Type '{ state: State.A; }[] | { state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
|
||||
Type '{ state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
|
||||
Type '{ state: State.B; }' is not assignable to type '{ state: State.A; }'.
|
||||
Types of property 'state' are incompatible.
|
||||
Type 'State.B' is not assignable to type 'State.A'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts (3 errors) ====
|
||||
// Repros from #5487
|
||||
|
||||
function truePromise(): Promise<true> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
interface Wrap<T> {
|
||||
value: T;
|
||||
}
|
||||
|
||||
function wrap<T>(value: T): Wrap<T> {
|
||||
return { value };
|
||||
}
|
||||
|
||||
function wrappedFoo(): Wrap<'foo'> {
|
||||
return wrap('foo');
|
||||
}
|
||||
|
||||
function wrapBar(value: 'bar'): Wrap<'bar'> {
|
||||
return { value };
|
||||
}
|
||||
|
||||
function wrappedBar(): Wrap<'bar'> {
|
||||
const value = 'bar';
|
||||
const inferred = wrapBar(value);
|
||||
const literal = wrapBar('bar');
|
||||
const value2: string = 'bar';
|
||||
const literal2 = wrapBar(value2); // Error
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"bar"'.
|
||||
return wrap(value);
|
||||
}
|
||||
|
||||
function wrappedBaz(): Wrap<'baz'> {
|
||||
const value: 'baz' = 'baz';
|
||||
return wrap(value);
|
||||
}
|
||||
|
||||
// Repro from #11152
|
||||
|
||||
interface FolderContentItem {
|
||||
type: 'folder' | 'file';
|
||||
}
|
||||
|
||||
let a: FolderContentItem[] = [];
|
||||
a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' }));
|
||||
|
||||
// Repro from #11312
|
||||
|
||||
let arr: Array<[number, number]> = [[1, 2]]
|
||||
|
||||
let mappedArr: Array<[number, number]> = arr.map(([x, y]) => {
|
||||
return [x, y];
|
||||
})
|
||||
|
||||
// Repro from #13594
|
||||
|
||||
export namespace DiagnosticSeverity {
|
||||
export const Error = 1;
|
||||
export const Warning = 2;
|
||||
export const Information = 3;
|
||||
export const Hint = 4;
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 1 | 2 | 3 | 4;
|
||||
|
||||
export interface Diagnostic {
|
||||
severity?: DiagnosticSeverity;
|
||||
code?: number | string;
|
||||
source?: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
function bug(): Diagnostic[] {
|
||||
let values: any[] = [];
|
||||
return values.map((value) => {
|
||||
return {
|
||||
severity: DiagnosticSeverity.Error,
|
||||
message: 'message'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Repro from #22870
|
||||
|
||||
function objectToMap(obj: any) {
|
||||
return new Map(Object.keys(obj).map(key => [key, obj[key]]));
|
||||
};
|
||||
|
||||
// Repro from #24352
|
||||
|
||||
interface Person {
|
||||
phoneNumbers: {
|
||||
__typename: 'PhoneNumber';
|
||||
}[];
|
||||
}
|
||||
|
||||
function createPerson(): Person {
|
||||
return {
|
||||
phoneNumbers: [1].map(() => ({
|
||||
__typename: 'PhoneNumber'
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
// Repro from #26621
|
||||
|
||||
type Box<T> = { value: T };
|
||||
declare function box<T>(value: T): Box<T>;
|
||||
|
||||
type WinCondition =
|
||||
| { type: 'win', player: string }
|
||||
| { type: 'draw' };
|
||||
|
||||
let zz: Box<WinCondition> = box({ type: 'draw' });
|
||||
|
||||
type WinType = 'win' | 'draw';
|
||||
|
||||
let yy: Box<WinType> = box('draw');
|
||||
|
||||
// Repro from #27074
|
||||
|
||||
interface OK<T> {
|
||||
kind: "OK";
|
||||
value: T;
|
||||
}
|
||||
export function ok<T>(value: T): OK<T> {
|
||||
return {
|
||||
kind: "OK",
|
||||
value: value
|
||||
};
|
||||
}
|
||||
|
||||
let result: OK<[string, number]> = ok(["hello", 12]);
|
||||
|
||||
// Repro from #25889
|
||||
|
||||
interface I {
|
||||
code: 'mapped',
|
||||
name: string,
|
||||
}
|
||||
|
||||
const a3: I[] = ['a', 'b'].map(name => {
|
||||
return {
|
||||
code: 'mapped',
|
||||
name,
|
||||
}
|
||||
});
|
||||
|
||||
// Repro from https://www.memsql.com/blog/porting-30k-lines-of-code-from-flow-to-typescript/
|
||||
|
||||
type Player = {
|
||||
name: string;
|
||||
age: number;
|
||||
position: "STRIKER" | "GOALKEEPER",
|
||||
};
|
||||
|
||||
type F = () => Promise<Array<Player>>;
|
||||
|
||||
const f1: F = () => {
|
||||
return Promise.all([
|
||||
{
|
||||
name: "David Gomes",
|
||||
age: 23,
|
||||
position: "GOALKEEPER",
|
||||
}, {
|
||||
name: "Cristiano Ronaldo",
|
||||
age: 33,
|
||||
position: "STRIKER",
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// Breaking change repros from #29478
|
||||
|
||||
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
|
||||
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'true'.
|
||||
!!! related TS6502 tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts:174:39: The expected type comes from the return type of this signature.
|
||||
|
||||
enum State { A, B }
|
||||
type Foo = { state: State }
|
||||
declare function bar<T>(f: () => T[]): T[];
|
||||
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ state: State.A; }[] | { state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
|
||||
!!! error TS2322: Type '{ state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
|
||||
!!! error TS2322: Type '{ state: State.B; }' is not assignable to type '{ state: State.A; }'.
|
||||
!!! error TS2322: Types of property 'state' are incompatible.
|
||||
!!! error TS2322: Type 'State.B' is not assignable to type 'State.A'.
|
||||
!!! related TS6502 tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts:179:28: The expected type comes from the return type of this signature.
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
//// [inferFromGenericFunctionReturnTypes3.ts]
|
||||
// Repros from #5487
|
||||
|
||||
function truePromise(): Promise<true> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
interface Wrap<T> {
|
||||
value: T;
|
||||
}
|
||||
|
||||
function wrap<T>(value: T): Wrap<T> {
|
||||
return { value };
|
||||
}
|
||||
|
||||
function wrappedFoo(): Wrap<'foo'> {
|
||||
return wrap('foo');
|
||||
}
|
||||
|
||||
function wrapBar(value: 'bar'): Wrap<'bar'> {
|
||||
return { value };
|
||||
}
|
||||
|
||||
function wrappedBar(): Wrap<'bar'> {
|
||||
const value = 'bar';
|
||||
const inferred = wrapBar(value);
|
||||
const literal = wrapBar('bar');
|
||||
const value2: string = 'bar';
|
||||
const literal2 = wrapBar(value2); // Error
|
||||
return wrap(value);
|
||||
}
|
||||
|
||||
function wrappedBaz(): Wrap<'baz'> {
|
||||
const value: 'baz' = 'baz';
|
||||
return wrap(value);
|
||||
}
|
||||
|
||||
// Repro from #11152
|
||||
|
||||
interface FolderContentItem {
|
||||
type: 'folder' | 'file';
|
||||
}
|
||||
|
||||
let a: FolderContentItem[] = [];
|
||||
a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' }));
|
||||
|
||||
// Repro from #11312
|
||||
|
||||
let arr: Array<[number, number]> = [[1, 2]]
|
||||
|
||||
let mappedArr: Array<[number, number]> = arr.map(([x, y]) => {
|
||||
return [x, y];
|
||||
})
|
||||
|
||||
// Repro from #13594
|
||||
|
||||
export namespace DiagnosticSeverity {
|
||||
export const Error = 1;
|
||||
export const Warning = 2;
|
||||
export const Information = 3;
|
||||
export const Hint = 4;
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 1 | 2 | 3 | 4;
|
||||
|
||||
export interface Diagnostic {
|
||||
severity?: DiagnosticSeverity;
|
||||
code?: number | string;
|
||||
source?: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
function bug(): Diagnostic[] {
|
||||
let values: any[] = [];
|
||||
return values.map((value) => {
|
||||
return {
|
||||
severity: DiagnosticSeverity.Error,
|
||||
message: 'message'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Repro from #22870
|
||||
|
||||
function objectToMap(obj: any) {
|
||||
return new Map(Object.keys(obj).map(key => [key, obj[key]]));
|
||||
};
|
||||
|
||||
// Repro from #24352
|
||||
|
||||
interface Person {
|
||||
phoneNumbers: {
|
||||
__typename: 'PhoneNumber';
|
||||
}[];
|
||||
}
|
||||
|
||||
function createPerson(): Person {
|
||||
return {
|
||||
phoneNumbers: [1].map(() => ({
|
||||
__typename: 'PhoneNumber'
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
// Repro from #26621
|
||||
|
||||
type Box<T> = { value: T };
|
||||
declare function box<T>(value: T): Box<T>;
|
||||
|
||||
type WinCondition =
|
||||
| { type: 'win', player: string }
|
||||
| { type: 'draw' };
|
||||
|
||||
let zz: Box<WinCondition> = box({ type: 'draw' });
|
||||
|
||||
type WinType = 'win' | 'draw';
|
||||
|
||||
let yy: Box<WinType> = box('draw');
|
||||
|
||||
// Repro from #27074
|
||||
|
||||
interface OK<T> {
|
||||
kind: "OK";
|
||||
value: T;
|
||||
}
|
||||
export function ok<T>(value: T): OK<T> {
|
||||
return {
|
||||
kind: "OK",
|
||||
value: value
|
||||
};
|
||||
}
|
||||
|
||||
let result: OK<[string, number]> = ok(["hello", 12]);
|
||||
|
||||
// Repro from #25889
|
||||
|
||||
interface I {
|
||||
code: 'mapped',
|
||||
name: string,
|
||||
}
|
||||
|
||||
const a3: I[] = ['a', 'b'].map(name => {
|
||||
return {
|
||||
code: 'mapped',
|
||||
name,
|
||||
}
|
||||
});
|
||||
|
||||
// Repro from https://www.memsql.com/blog/porting-30k-lines-of-code-from-flow-to-typescript/
|
||||
|
||||
type Player = {
|
||||
name: string;
|
||||
age: number;
|
||||
position: "STRIKER" | "GOALKEEPER",
|
||||
};
|
||||
|
||||
type F = () => Promise<Array<Player>>;
|
||||
|
||||
const f1: F = () => {
|
||||
return Promise.all([
|
||||
{
|
||||
name: "David Gomes",
|
||||
age: 23,
|
||||
position: "GOALKEEPER",
|
||||
}, {
|
||||
name: "Cristiano Ronaldo",
|
||||
age: 33,
|
||||
position: "STRIKER",
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// Breaking change repros from #29478
|
||||
|
||||
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
|
||||
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
|
||||
|
||||
enum State { A, B }
|
||||
type Foo = { state: State }
|
||||
declare function bar<T>(f: () => T[]): T[];
|
||||
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes3.js]
|
||||
// Repros from #5487
|
||||
function truePromise() {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
function wrap(value) {
|
||||
return { value };
|
||||
}
|
||||
function wrappedFoo() {
|
||||
return wrap('foo');
|
||||
}
|
||||
function wrapBar(value) {
|
||||
return { value };
|
||||
}
|
||||
function wrappedBar() {
|
||||
const value = 'bar';
|
||||
const inferred = wrapBar(value);
|
||||
const literal = wrapBar('bar');
|
||||
const value2 = 'bar';
|
||||
const literal2 = wrapBar(value2); // Error
|
||||
return wrap(value);
|
||||
}
|
||||
function wrappedBaz() {
|
||||
const value = 'baz';
|
||||
return wrap(value);
|
||||
}
|
||||
let a = [];
|
||||
a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' }));
|
||||
// Repro from #11312
|
||||
let arr = [[1, 2]];
|
||||
let mappedArr = arr.map(([x, y]) => {
|
||||
return [x, y];
|
||||
});
|
||||
// Repro from #13594
|
||||
export var DiagnosticSeverity;
|
||||
(function (DiagnosticSeverity) {
|
||||
DiagnosticSeverity.Error = 1;
|
||||
DiagnosticSeverity.Warning = 2;
|
||||
DiagnosticSeverity.Information = 3;
|
||||
DiagnosticSeverity.Hint = 4;
|
||||
})(DiagnosticSeverity || (DiagnosticSeverity = {}));
|
||||
function bug() {
|
||||
let values = [];
|
||||
return values.map((value) => {
|
||||
return {
|
||||
severity: DiagnosticSeverity.Error,
|
||||
message: 'message'
|
||||
};
|
||||
});
|
||||
}
|
||||
// Repro from #22870
|
||||
function objectToMap(obj) {
|
||||
return new Map(Object.keys(obj).map(key => [key, obj[key]]));
|
||||
}
|
||||
;
|
||||
function createPerson() {
|
||||
return {
|
||||
phoneNumbers: [1].map(() => ({
|
||||
__typename: 'PhoneNumber'
|
||||
}))
|
||||
};
|
||||
}
|
||||
let zz = box({ type: 'draw' });
|
||||
let yy = box('draw');
|
||||
export function ok(value) {
|
||||
return {
|
||||
kind: "OK",
|
||||
value: value
|
||||
};
|
||||
}
|
||||
let result = ok(["hello", 12]);
|
||||
const a3 = ['a', 'b'].map(name => {
|
||||
return {
|
||||
code: 'mapped',
|
||||
name,
|
||||
};
|
||||
});
|
||||
const f1 = () => {
|
||||
return Promise.all([
|
||||
{
|
||||
name: "David Gomes",
|
||||
age: 23,
|
||||
position: "GOALKEEPER",
|
||||
}, {
|
||||
name: "Cristiano Ronaldo",
|
||||
age: 33,
|
||||
position: "STRIKER",
|
||||
}
|
||||
]);
|
||||
};
|
||||
let res = foldLeft(true, (acc, t) => acc && t); // Error
|
||||
var State;
|
||||
(function (State) {
|
||||
State[State["A"] = 0] = "A";
|
||||
State[State["B"] = 1] = "B";
|
||||
})(State || (State = {}));
|
||||
let x = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes3.d.ts]
|
||||
export declare namespace DiagnosticSeverity {
|
||||
const Error = 1;
|
||||
const Warning = 2;
|
||||
const Information = 3;
|
||||
const Hint = 4;
|
||||
}
|
||||
export declare type DiagnosticSeverity = 1 | 2 | 3 | 4;
|
||||
export interface Diagnostic {
|
||||
severity?: DiagnosticSeverity;
|
||||
code?: number | string;
|
||||
source?: string;
|
||||
message: string;
|
||||
}
|
||||
interface OK<T> {
|
||||
kind: "OK";
|
||||
value: T;
|
||||
}
|
||||
export declare function ok<T>(value: T): OK<T>;
|
||||
export {};
|
||||
@@ -0,0 +1,461 @@
|
||||
=== tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts ===
|
||||
// Repros from #5487
|
||||
|
||||
function truePromise(): Promise<true> {
|
||||
>truePromise : Symbol(truePromise, Decl(inferFromGenericFunctionReturnTypes3.ts, 0, 0))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
return Promise.resolve(true);
|
||||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
}
|
||||
|
||||
interface Wrap<T> {
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 6, 15))
|
||||
|
||||
value: T;
|
||||
>value : Symbol(Wrap.value, Decl(inferFromGenericFunctionReturnTypes3.ts, 6, 19))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 6, 15))
|
||||
}
|
||||
|
||||
function wrap<T>(value: T): Wrap<T> {
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 8, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 10, 14))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 10, 17))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 10, 14))
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 10, 14))
|
||||
|
||||
return { value };
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 11, 12))
|
||||
}
|
||||
|
||||
function wrappedFoo(): Wrap<'foo'> {
|
||||
>wrappedFoo : Symbol(wrappedFoo, Decl(inferFromGenericFunctionReturnTypes3.ts, 12, 1))
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
|
||||
return wrap('foo');
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 8, 1))
|
||||
}
|
||||
|
||||
function wrapBar(value: 'bar'): Wrap<'bar'> {
|
||||
>wrapBar : Symbol(wrapBar, Decl(inferFromGenericFunctionReturnTypes3.ts, 16, 1))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 18, 17))
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
|
||||
return { value };
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 19, 12))
|
||||
}
|
||||
|
||||
function wrappedBar(): Wrap<'bar'> {
|
||||
>wrappedBar : Symbol(wrappedBar, Decl(inferFromGenericFunctionReturnTypes3.ts, 20, 1))
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
|
||||
const value = 'bar';
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 23, 9))
|
||||
|
||||
const inferred = wrapBar(value);
|
||||
>inferred : Symbol(inferred, Decl(inferFromGenericFunctionReturnTypes3.ts, 24, 9))
|
||||
>wrapBar : Symbol(wrapBar, Decl(inferFromGenericFunctionReturnTypes3.ts, 16, 1))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 23, 9))
|
||||
|
||||
const literal = wrapBar('bar');
|
||||
>literal : Symbol(literal, Decl(inferFromGenericFunctionReturnTypes3.ts, 25, 9))
|
||||
>wrapBar : Symbol(wrapBar, Decl(inferFromGenericFunctionReturnTypes3.ts, 16, 1))
|
||||
|
||||
const value2: string = 'bar';
|
||||
>value2 : Symbol(value2, Decl(inferFromGenericFunctionReturnTypes3.ts, 26, 9))
|
||||
|
||||
const literal2 = wrapBar(value2); // Error
|
||||
>literal2 : Symbol(literal2, Decl(inferFromGenericFunctionReturnTypes3.ts, 27, 9))
|
||||
>wrapBar : Symbol(wrapBar, Decl(inferFromGenericFunctionReturnTypes3.ts, 16, 1))
|
||||
>value2 : Symbol(value2, Decl(inferFromGenericFunctionReturnTypes3.ts, 26, 9))
|
||||
|
||||
return wrap(value);
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 8, 1))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 23, 9))
|
||||
}
|
||||
|
||||
function wrappedBaz(): Wrap<'baz'> {
|
||||
>wrappedBaz : Symbol(wrappedBaz, Decl(inferFromGenericFunctionReturnTypes3.ts, 29, 1))
|
||||
>Wrap : Symbol(Wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 4, 1))
|
||||
|
||||
const value: 'baz' = 'baz';
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 32, 9))
|
||||
|
||||
return wrap(value);
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes3.ts, 8, 1))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 32, 9))
|
||||
}
|
||||
|
||||
// Repro from #11152
|
||||
|
||||
interface FolderContentItem {
|
||||
>FolderContentItem : Symbol(FolderContentItem, Decl(inferFromGenericFunctionReturnTypes3.ts, 34, 1))
|
||||
|
||||
type: 'folder' | 'file';
|
||||
>type : Symbol(FolderContentItem.type, Decl(inferFromGenericFunctionReturnTypes3.ts, 38, 29))
|
||||
}
|
||||
|
||||
let a: FolderContentItem[] = [];
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes3.ts, 42, 3))
|
||||
>FolderContentItem : Symbol(FolderContentItem, Decl(inferFromGenericFunctionReturnTypes3.ts, 34, 1))
|
||||
|
||||
a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' }));
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes3.ts, 42, 3))
|
||||
>[1, 2, 3, 4, 5].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>v : Symbol(v, Decl(inferFromGenericFunctionReturnTypes3.ts, 43, 24))
|
||||
>type : Symbol(type, Decl(inferFromGenericFunctionReturnTypes3.ts, 43, 31))
|
||||
|
||||
// Repro from #11312
|
||||
|
||||
let arr: Array<[number, number]> = [[1, 2]]
|
||||
>arr : Symbol(arr, Decl(inferFromGenericFunctionReturnTypes3.ts, 47, 3))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
|
||||
let mappedArr: Array<[number, number]> = arr.map(([x, y]) => {
|
||||
>mappedArr : Symbol(mappedArr, Decl(inferFromGenericFunctionReturnTypes3.ts, 49, 3))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>arr.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>arr : Symbol(arr, Decl(inferFromGenericFunctionReturnTypes3.ts, 47, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 49, 51))
|
||||
>y : Symbol(y, Decl(inferFromGenericFunctionReturnTypes3.ts, 49, 53))
|
||||
|
||||
return [x, y];
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 49, 51))
|
||||
>y : Symbol(y, Decl(inferFromGenericFunctionReturnTypes3.ts, 49, 53))
|
||||
|
||||
})
|
||||
|
||||
// Repro from #13594
|
||||
|
||||
export namespace DiagnosticSeverity {
|
||||
>DiagnosticSeverity : Symbol(DiagnosticSeverity, Decl(inferFromGenericFunctionReturnTypes3.ts, 51, 2), Decl(inferFromGenericFunctionReturnTypes3.ts, 60, 1))
|
||||
|
||||
export const Error = 1;
|
||||
>Error : Symbol(Error, Decl(inferFromGenericFunctionReturnTypes3.ts, 56, 13))
|
||||
|
||||
export const Warning = 2;
|
||||
>Warning : Symbol(Warning, Decl(inferFromGenericFunctionReturnTypes3.ts, 57, 13))
|
||||
|
||||
export const Information = 3;
|
||||
>Information : Symbol(Information, Decl(inferFromGenericFunctionReturnTypes3.ts, 58, 13))
|
||||
|
||||
export const Hint = 4;
|
||||
>Hint : Symbol(Hint, Decl(inferFromGenericFunctionReturnTypes3.ts, 59, 13))
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 1 | 2 | 3 | 4;
|
||||
>DiagnosticSeverity : Symbol(DiagnosticSeverity, Decl(inferFromGenericFunctionReturnTypes3.ts, 51, 2), Decl(inferFromGenericFunctionReturnTypes3.ts, 60, 1))
|
||||
|
||||
export interface Diagnostic {
|
||||
>Diagnostic : Symbol(Diagnostic, Decl(inferFromGenericFunctionReturnTypes3.ts, 62, 47))
|
||||
|
||||
severity?: DiagnosticSeverity;
|
||||
>severity : Symbol(Diagnostic.severity, Decl(inferFromGenericFunctionReturnTypes3.ts, 64, 29))
|
||||
>DiagnosticSeverity : Symbol(DiagnosticSeverity, Decl(inferFromGenericFunctionReturnTypes3.ts, 51, 2), Decl(inferFromGenericFunctionReturnTypes3.ts, 60, 1))
|
||||
|
||||
code?: number | string;
|
||||
>code : Symbol(Diagnostic.code, Decl(inferFromGenericFunctionReturnTypes3.ts, 65, 31))
|
||||
|
||||
source?: string;
|
||||
>source : Symbol(Diagnostic.source, Decl(inferFromGenericFunctionReturnTypes3.ts, 66, 24))
|
||||
|
||||
message: string;
|
||||
>message : Symbol(Diagnostic.message, Decl(inferFromGenericFunctionReturnTypes3.ts, 67, 17))
|
||||
}
|
||||
|
||||
function bug(): Diagnostic[] {
|
||||
>bug : Symbol(bug, Decl(inferFromGenericFunctionReturnTypes3.ts, 69, 1))
|
||||
>Diagnostic : Symbol(Diagnostic, Decl(inferFromGenericFunctionReturnTypes3.ts, 62, 47))
|
||||
|
||||
let values: any[] = [];
|
||||
>values : Symbol(values, Decl(inferFromGenericFunctionReturnTypes3.ts, 72, 4))
|
||||
|
||||
return values.map((value) => {
|
||||
>values.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>values : Symbol(values, Decl(inferFromGenericFunctionReturnTypes3.ts, 72, 4))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 73, 20))
|
||||
|
||||
return {
|
||||
severity: DiagnosticSeverity.Error,
|
||||
>severity : Symbol(severity, Decl(inferFromGenericFunctionReturnTypes3.ts, 74, 10))
|
||||
>DiagnosticSeverity.Error : Symbol(DiagnosticSeverity.Error, Decl(inferFromGenericFunctionReturnTypes3.ts, 56, 13))
|
||||
>DiagnosticSeverity : Symbol(DiagnosticSeverity, Decl(inferFromGenericFunctionReturnTypes3.ts, 51, 2), Decl(inferFromGenericFunctionReturnTypes3.ts, 60, 1))
|
||||
>Error : Symbol(DiagnosticSeverity.Error, Decl(inferFromGenericFunctionReturnTypes3.ts, 56, 13))
|
||||
|
||||
message: 'message'
|
||||
>message : Symbol(message, Decl(inferFromGenericFunctionReturnTypes3.ts, 75, 38))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Repro from #22870
|
||||
|
||||
function objectToMap(obj: any) {
|
||||
>objectToMap : Symbol(objectToMap, Decl(inferFromGenericFunctionReturnTypes3.ts, 79, 1))
|
||||
>obj : Symbol(obj, Decl(inferFromGenericFunctionReturnTypes3.ts, 83, 21))
|
||||
|
||||
return new Map(Object.keys(obj).map(key => [key, obj[key]]));
|
||||
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Object.keys(obj).map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>Object.keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
|
||||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>keys : Symbol(ObjectConstructor.keys, Decl(lib.es5.d.ts, --, --))
|
||||
>obj : Symbol(obj, Decl(inferFromGenericFunctionReturnTypes3.ts, 83, 21))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>key : Symbol(key, Decl(inferFromGenericFunctionReturnTypes3.ts, 84, 37))
|
||||
>key : Symbol(key, Decl(inferFromGenericFunctionReturnTypes3.ts, 84, 37))
|
||||
>obj : Symbol(obj, Decl(inferFromGenericFunctionReturnTypes3.ts, 83, 21))
|
||||
>key : Symbol(key, Decl(inferFromGenericFunctionReturnTypes3.ts, 84, 37))
|
||||
|
||||
};
|
||||
|
||||
// Repro from #24352
|
||||
|
||||
interface Person {
|
||||
>Person : Symbol(Person, Decl(inferFromGenericFunctionReturnTypes3.ts, 85, 2))
|
||||
|
||||
phoneNumbers: {
|
||||
>phoneNumbers : Symbol(Person.phoneNumbers, Decl(inferFromGenericFunctionReturnTypes3.ts, 89, 18))
|
||||
|
||||
__typename: 'PhoneNumber';
|
||||
>__typename : Symbol(__typename, Decl(inferFromGenericFunctionReturnTypes3.ts, 90, 17))
|
||||
|
||||
}[];
|
||||
}
|
||||
|
||||
function createPerson(): Person {
|
||||
>createPerson : Symbol(createPerson, Decl(inferFromGenericFunctionReturnTypes3.ts, 93, 1))
|
||||
>Person : Symbol(Person, Decl(inferFromGenericFunctionReturnTypes3.ts, 85, 2))
|
||||
|
||||
return {
|
||||
phoneNumbers: [1].map(() => ({
|
||||
>phoneNumbers : Symbol(phoneNumbers, Decl(inferFromGenericFunctionReturnTypes3.ts, 96, 10))
|
||||
>[1].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
__typename: 'PhoneNumber'
|
||||
>__typename : Symbol(__typename, Decl(inferFromGenericFunctionReturnTypes3.ts, 97, 34))
|
||||
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
// Repro from #26621
|
||||
|
||||
type Box<T> = { value: T };
|
||||
>Box : Symbol(Box, Decl(inferFromGenericFunctionReturnTypes3.ts, 101, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 9))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 15))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 9))
|
||||
|
||||
declare function box<T>(value: T): Box<T>;
|
||||
>box : Symbol(box, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 27))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 21))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 24))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 21))
|
||||
>Box : Symbol(Box, Decl(inferFromGenericFunctionReturnTypes3.ts, 101, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 21))
|
||||
|
||||
type WinCondition =
|
||||
>WinCondition : Symbol(WinCondition, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 42))
|
||||
|
||||
| { type: 'win', player: string }
|
||||
>type : Symbol(type, Decl(inferFromGenericFunctionReturnTypes3.ts, 109, 7))
|
||||
>player : Symbol(player, Decl(inferFromGenericFunctionReturnTypes3.ts, 109, 20))
|
||||
|
||||
| { type: 'draw' };
|
||||
>type : Symbol(type, Decl(inferFromGenericFunctionReturnTypes3.ts, 110, 7))
|
||||
|
||||
let zz: Box<WinCondition> = box({ type: 'draw' });
|
||||
>zz : Symbol(zz, Decl(inferFromGenericFunctionReturnTypes3.ts, 112, 3))
|
||||
>Box : Symbol(Box, Decl(inferFromGenericFunctionReturnTypes3.ts, 101, 1))
|
||||
>WinCondition : Symbol(WinCondition, Decl(inferFromGenericFunctionReturnTypes3.ts, 106, 42))
|
||||
>box : Symbol(box, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 27))
|
||||
>type : Symbol(type, Decl(inferFromGenericFunctionReturnTypes3.ts, 112, 33))
|
||||
|
||||
type WinType = 'win' | 'draw';
|
||||
>WinType : Symbol(WinType, Decl(inferFromGenericFunctionReturnTypes3.ts, 112, 50))
|
||||
|
||||
let yy: Box<WinType> = box('draw');
|
||||
>yy : Symbol(yy, Decl(inferFromGenericFunctionReturnTypes3.ts, 116, 3))
|
||||
>Box : Symbol(Box, Decl(inferFromGenericFunctionReturnTypes3.ts, 101, 1))
|
||||
>WinType : Symbol(WinType, Decl(inferFromGenericFunctionReturnTypes3.ts, 112, 50))
|
||||
>box : Symbol(box, Decl(inferFromGenericFunctionReturnTypes3.ts, 105, 27))
|
||||
|
||||
// Repro from #27074
|
||||
|
||||
interface OK<T> {
|
||||
>OK : Symbol(OK, Decl(inferFromGenericFunctionReturnTypes3.ts, 116, 35))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 120, 13))
|
||||
|
||||
kind: "OK";
|
||||
>kind : Symbol(OK.kind, Decl(inferFromGenericFunctionReturnTypes3.ts, 120, 17))
|
||||
|
||||
value: T;
|
||||
>value : Symbol(OK.value, Decl(inferFromGenericFunctionReturnTypes3.ts, 121, 15))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 120, 13))
|
||||
}
|
||||
export function ok<T>(value: T): OK<T> {
|
||||
>ok : Symbol(ok, Decl(inferFromGenericFunctionReturnTypes3.ts, 123, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 124, 19))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 124, 22))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 124, 19))
|
||||
>OK : Symbol(OK, Decl(inferFromGenericFunctionReturnTypes3.ts, 116, 35))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 124, 19))
|
||||
|
||||
return {
|
||||
kind: "OK",
|
||||
>kind : Symbol(kind, Decl(inferFromGenericFunctionReturnTypes3.ts, 125, 12))
|
||||
|
||||
value: value
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 126, 19))
|
||||
>value : Symbol(value, Decl(inferFromGenericFunctionReturnTypes3.ts, 124, 22))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
let result: OK<[string, number]> = ok(["hello", 12]);
|
||||
>result : Symbol(result, Decl(inferFromGenericFunctionReturnTypes3.ts, 131, 3))
|
||||
>OK : Symbol(OK, Decl(inferFromGenericFunctionReturnTypes3.ts, 116, 35))
|
||||
>ok : Symbol(ok, Decl(inferFromGenericFunctionReturnTypes3.ts, 123, 1))
|
||||
|
||||
// Repro from #25889
|
||||
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(inferFromGenericFunctionReturnTypes3.ts, 131, 53))
|
||||
|
||||
code: 'mapped',
|
||||
>code : Symbol(I.code, Decl(inferFromGenericFunctionReturnTypes3.ts, 135, 13))
|
||||
|
||||
name: string,
|
||||
>name : Symbol(I.name, Decl(inferFromGenericFunctionReturnTypes3.ts, 136, 19))
|
||||
}
|
||||
|
||||
const a3: I[] = ['a', 'b'].map(name => {
|
||||
>a3 : Symbol(a3, Decl(inferFromGenericFunctionReturnTypes3.ts, 140, 5))
|
||||
>I : Symbol(I, Decl(inferFromGenericFunctionReturnTypes3.ts, 131, 53))
|
||||
>['a', 'b'].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
|
||||
>name : Symbol(name, Decl(inferFromGenericFunctionReturnTypes3.ts, 140, 31))
|
||||
|
||||
return {
|
||||
code: 'mapped',
|
||||
>code : Symbol(code, Decl(inferFromGenericFunctionReturnTypes3.ts, 141, 12))
|
||||
|
||||
name,
|
||||
>name : Symbol(name, Decl(inferFromGenericFunctionReturnTypes3.ts, 142, 23))
|
||||
}
|
||||
});
|
||||
|
||||
// Repro from https://www.memsql.com/blog/porting-30k-lines-of-code-from-flow-to-typescript/
|
||||
|
||||
type Player = {
|
||||
>Player : Symbol(Player, Decl(inferFromGenericFunctionReturnTypes3.ts, 145, 3))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(name, Decl(inferFromGenericFunctionReturnTypes3.ts, 149, 15))
|
||||
|
||||
age: number;
|
||||
>age : Symbol(age, Decl(inferFromGenericFunctionReturnTypes3.ts, 150, 17))
|
||||
|
||||
position: "STRIKER" | "GOALKEEPER",
|
||||
>position : Symbol(position, Decl(inferFromGenericFunctionReturnTypes3.ts, 151, 16))
|
||||
|
||||
};
|
||||
|
||||
type F = () => Promise<Array<Player>>;
|
||||
>F : Symbol(F, Decl(inferFromGenericFunctionReturnTypes3.ts, 153, 2))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Player : Symbol(Player, Decl(inferFromGenericFunctionReturnTypes3.ts, 145, 3))
|
||||
|
||||
const f1: F = () => {
|
||||
>f1 : Symbol(f1, Decl(inferFromGenericFunctionReturnTypes3.ts, 157, 5))
|
||||
>F : Symbol(F, Decl(inferFromGenericFunctionReturnTypes3.ts, 153, 2))
|
||||
|
||||
return Promise.all([
|
||||
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --) ... and 6 more)
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --) ... and 6 more)
|
||||
{
|
||||
name: "David Gomes",
|
||||
>name : Symbol(name, Decl(inferFromGenericFunctionReturnTypes3.ts, 159, 9))
|
||||
|
||||
age: 23,
|
||||
>age : Symbol(age, Decl(inferFromGenericFunctionReturnTypes3.ts, 160, 32))
|
||||
|
||||
position: "GOALKEEPER",
|
||||
>position : Symbol(position, Decl(inferFromGenericFunctionReturnTypes3.ts, 161, 20))
|
||||
|
||||
}, {
|
||||
name: "Cristiano Ronaldo",
|
||||
>name : Symbol(name, Decl(inferFromGenericFunctionReturnTypes3.ts, 163, 12))
|
||||
|
||||
age: 33,
|
||||
>age : Symbol(age, Decl(inferFromGenericFunctionReturnTypes3.ts, 164, 38))
|
||||
|
||||
position: "STRIKER",
|
||||
>position : Symbol(position, Decl(inferFromGenericFunctionReturnTypes3.ts, 165, 20))
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// Breaking change repros from #29478
|
||||
|
||||
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
|
||||
>foldLeft : Symbol(foldLeft, Decl(inferFromGenericFunctionReturnTypes3.ts, 169, 2))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
|
||||
>z : Symbol(z, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 29))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
|
||||
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 34))
|
||||
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 39))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
|
||||
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 46))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
|
||||
|
||||
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
|
||||
>res : Symbol(res, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 3))
|
||||
>foldLeft : Symbol(foldLeft, Decl(inferFromGenericFunctionReturnTypes3.ts, 169, 2))
|
||||
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 35))
|
||||
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 39))
|
||||
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 35))
|
||||
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 39))
|
||||
|
||||
enum State { A, B }
|
||||
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
|
||||
>A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
|
||||
>B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
|
||||
|
||||
type Foo = { state: State }
|
||||
>Foo : Symbol(Foo, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 19))
|
||||
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 12))
|
||||
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
|
||||
|
||||
declare function bar<T>(f: () => T[]): T[];
|
||||
>bar : Symbol(bar, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 27))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
|
||||
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 24))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
|
||||
|
||||
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 3))
|
||||
>Foo : Symbol(Foo, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 19))
|
||||
>bar : Symbol(bar, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 27))
|
||||
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 36))
|
||||
>State.A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
|
||||
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
|
||||
>A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
|
||||
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 59))
|
||||
>State.B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
|
||||
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
|
||||
>B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
|
||||
|
||||
@@ -0,0 +1,508 @@
|
||||
=== tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts ===
|
||||
// Repros from #5487
|
||||
|
||||
function truePromise(): Promise<true> {
|
||||
>truePromise : () => Promise<true>
|
||||
>true : true
|
||||
|
||||
return Promise.resolve(true);
|
||||
>Promise.resolve(true) : Promise<true>
|
||||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>Promise : PromiseConstructor
|
||||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>true : true
|
||||
}
|
||||
|
||||
interface Wrap<T> {
|
||||
value: T;
|
||||
>value : T
|
||||
}
|
||||
|
||||
function wrap<T>(value: T): Wrap<T> {
|
||||
>wrap : <T>(value: T) => Wrap<T>
|
||||
>value : T
|
||||
|
||||
return { value };
|
||||
>{ value } : { value: T; }
|
||||
>value : T
|
||||
}
|
||||
|
||||
function wrappedFoo(): Wrap<'foo'> {
|
||||
>wrappedFoo : () => Wrap<"foo">
|
||||
|
||||
return wrap('foo');
|
||||
>wrap('foo') : Wrap<"foo">
|
||||
>wrap : <T>(value: T) => Wrap<T>
|
||||
>'foo' : "foo"
|
||||
}
|
||||
|
||||
function wrapBar(value: 'bar'): Wrap<'bar'> {
|
||||
>wrapBar : (value: "bar") => Wrap<"bar">
|
||||
>value : "bar"
|
||||
|
||||
return { value };
|
||||
>{ value } : { value: "bar"; }
|
||||
>value : "bar"
|
||||
}
|
||||
|
||||
function wrappedBar(): Wrap<'bar'> {
|
||||
>wrappedBar : () => Wrap<"bar">
|
||||
|
||||
const value = 'bar';
|
||||
>value : "bar"
|
||||
>'bar' : "bar"
|
||||
|
||||
const inferred = wrapBar(value);
|
||||
>inferred : Wrap<"bar">
|
||||
>wrapBar(value) : Wrap<"bar">
|
||||
>wrapBar : (value: "bar") => Wrap<"bar">
|
||||
>value : "bar"
|
||||
|
||||
const literal = wrapBar('bar');
|
||||
>literal : Wrap<"bar">
|
||||
>wrapBar('bar') : Wrap<"bar">
|
||||
>wrapBar : (value: "bar") => Wrap<"bar">
|
||||
>'bar' : "bar"
|
||||
|
||||
const value2: string = 'bar';
|
||||
>value2 : string
|
||||
>'bar' : "bar"
|
||||
|
||||
const literal2 = wrapBar(value2); // Error
|
||||
>literal2 : Wrap<"bar">
|
||||
>wrapBar(value2) : Wrap<"bar">
|
||||
>wrapBar : (value: "bar") => Wrap<"bar">
|
||||
>value2 : string
|
||||
|
||||
return wrap(value);
|
||||
>wrap(value) : Wrap<"bar">
|
||||
>wrap : <T>(value: T) => Wrap<T>
|
||||
>value : "bar"
|
||||
}
|
||||
|
||||
function wrappedBaz(): Wrap<'baz'> {
|
||||
>wrappedBaz : () => Wrap<"baz">
|
||||
|
||||
const value: 'baz' = 'baz';
|
||||
>value : "baz"
|
||||
>'baz' : "baz"
|
||||
|
||||
return wrap(value);
|
||||
>wrap(value) : Wrap<"baz">
|
||||
>wrap : <T>(value: T) => Wrap<T>
|
||||
>value : "baz"
|
||||
}
|
||||
|
||||
// Repro from #11152
|
||||
|
||||
interface FolderContentItem {
|
||||
type: 'folder' | 'file';
|
||||
>type : "folder" | "file"
|
||||
}
|
||||
|
||||
let a: FolderContentItem[] = [];
|
||||
>a : FolderContentItem[]
|
||||
>[] : never[]
|
||||
|
||||
a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' }));
|
||||
>a = [1, 2, 3, 4, 5].map(v => ({ type: 'folder' })) : { type: "folder"; }[]
|
||||
>a : FolderContentItem[]
|
||||
>[1, 2, 3, 4, 5].map(v => ({ type: 'folder' })) : { type: "folder"; }[]
|
||||
>[1, 2, 3, 4, 5].map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>[1, 2, 3, 4, 5] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
>4 : 4
|
||||
>5 : 5
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>v => ({ type: 'folder' }) : (v: number) => { type: "folder"; }
|
||||
>v : number
|
||||
>({ type: 'folder' }) : { type: "folder"; }
|
||||
>{ type: 'folder' } : { type: "folder"; }
|
||||
>type : "folder"
|
||||
>'folder' : "folder"
|
||||
|
||||
// Repro from #11312
|
||||
|
||||
let arr: Array<[number, number]> = [[1, 2]]
|
||||
>arr : [number, number][]
|
||||
>[[1, 2]] : [number, number][]
|
||||
>[1, 2] : [number, number]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
let mappedArr: Array<[number, number]> = arr.map(([x, y]) => {
|
||||
>mappedArr : [number, number][]
|
||||
>arr.map(([x, y]) => { return [x, y];}) : [number, number][]
|
||||
>arr.map : <U>(callbackfn: (value: [number, number], index: number, array: [number, number][]) => U, thisArg?: any) => U[]
|
||||
>arr : [number, number][]
|
||||
>map : <U>(callbackfn: (value: [number, number], index: number, array: [number, number][]) => U, thisArg?: any) => U[]
|
||||
>([x, y]) => { return [x, y];} : ([x, y]: [number, number]) => [number, number]
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
return [x, y];
|
||||
>[x, y] : [number, number]
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
})
|
||||
|
||||
// Repro from #13594
|
||||
|
||||
export namespace DiagnosticSeverity {
|
||||
>DiagnosticSeverity : typeof DiagnosticSeverity
|
||||
|
||||
export const Error = 1;
|
||||
>Error : 1
|
||||
>1 : 1
|
||||
|
||||
export const Warning = 2;
|
||||
>Warning : 2
|
||||
>2 : 2
|
||||
|
||||
export const Information = 3;
|
||||
>Information : 3
|
||||
>3 : 3
|
||||
|
||||
export const Hint = 4;
|
||||
>Hint : 4
|
||||
>4 : 4
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 1 | 2 | 3 | 4;
|
||||
>DiagnosticSeverity : DiagnosticSeverity
|
||||
|
||||
export interface Diagnostic {
|
||||
severity?: DiagnosticSeverity;
|
||||
>severity : 1 | 2 | 3 | 4 | undefined
|
||||
|
||||
code?: number | string;
|
||||
>code : string | number | undefined
|
||||
|
||||
source?: string;
|
||||
>source : string | undefined
|
||||
|
||||
message: string;
|
||||
>message : string
|
||||
}
|
||||
|
||||
function bug(): Diagnostic[] {
|
||||
>bug : () => Diagnostic[]
|
||||
|
||||
let values: any[] = [];
|
||||
>values : any[]
|
||||
>[] : never[]
|
||||
|
||||
return values.map((value) => {
|
||||
>values.map((value) => { return { severity: DiagnosticSeverity.Error, message: 'message' } }) : { severity: 1; message: string; }[]
|
||||
>values.map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>values : any[]
|
||||
>map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>(value) => { return { severity: DiagnosticSeverity.Error, message: 'message' } } : (value: any) => { severity: 1; message: string; }
|
||||
>value : any
|
||||
|
||||
return {
|
||||
>{ severity: DiagnosticSeverity.Error, message: 'message' } : { severity: 1; message: string; }
|
||||
|
||||
severity: DiagnosticSeverity.Error,
|
||||
>severity : 1
|
||||
>DiagnosticSeverity.Error : 1
|
||||
>DiagnosticSeverity : typeof DiagnosticSeverity
|
||||
>Error : 1
|
||||
|
||||
message: 'message'
|
||||
>message : string
|
||||
>'message' : "message"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Repro from #22870
|
||||
|
||||
function objectToMap(obj: any) {
|
||||
>objectToMap : (obj: any) => Map<string, any>
|
||||
>obj : any
|
||||
|
||||
return new Map(Object.keys(obj).map(key => [key, obj[key]]));
|
||||
>new Map(Object.keys(obj).map(key => [key, obj[key]])) : Map<string, any>
|
||||
>Map : MapConstructor
|
||||
>Object.keys(obj).map(key => [key, obj[key]]) : [string, any][]
|
||||
>Object.keys(obj).map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>Object.keys(obj) : string[]
|
||||
>Object.keys : (o: {}) => string[]
|
||||
>Object : ObjectConstructor
|
||||
>keys : (o: {}) => string[]
|
||||
>obj : any
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>key => [key, obj[key]] : (key: string) => [string, any]
|
||||
>key : string
|
||||
>[key, obj[key]] : [string, any]
|
||||
>key : string
|
||||
>obj[key] : any
|
||||
>obj : any
|
||||
>key : string
|
||||
|
||||
};
|
||||
|
||||
// Repro from #24352
|
||||
|
||||
interface Person {
|
||||
phoneNumbers: {
|
||||
>phoneNumbers : { __typename: "PhoneNumber"; }[]
|
||||
|
||||
__typename: 'PhoneNumber';
|
||||
>__typename : "PhoneNumber"
|
||||
|
||||
}[];
|
||||
}
|
||||
|
||||
function createPerson(): Person {
|
||||
>createPerson : () => Person
|
||||
|
||||
return {
|
||||
>{ phoneNumbers: [1].map(() => ({ __typename: 'PhoneNumber' })) } : { phoneNumbers: { __typename: "PhoneNumber"; }[]; }
|
||||
|
||||
phoneNumbers: [1].map(() => ({
|
||||
>phoneNumbers : { __typename: "PhoneNumber"; }[]
|
||||
>[1].map(() => ({ __typename: 'PhoneNumber' })) : { __typename: "PhoneNumber"; }[]
|
||||
>[1].map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>[1] : number[]
|
||||
>1 : 1
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>() => ({ __typename: 'PhoneNumber' }) : () => { __typename: "PhoneNumber"; }
|
||||
>({ __typename: 'PhoneNumber' }) : { __typename: "PhoneNumber"; }
|
||||
>{ __typename: 'PhoneNumber' } : { __typename: "PhoneNumber"; }
|
||||
|
||||
__typename: 'PhoneNumber'
|
||||
>__typename : "PhoneNumber"
|
||||
>'PhoneNumber' : "PhoneNumber"
|
||||
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
// Repro from #26621
|
||||
|
||||
type Box<T> = { value: T };
|
||||
>Box : Box<T>
|
||||
>value : T
|
||||
|
||||
declare function box<T>(value: T): Box<T>;
|
||||
>box : <T>(value: T) => Box<T>
|
||||
>value : T
|
||||
|
||||
type WinCondition =
|
||||
>WinCondition : WinCondition
|
||||
|
||||
| { type: 'win', player: string }
|
||||
>type : "win"
|
||||
>player : string
|
||||
|
||||
| { type: 'draw' };
|
||||
>type : "draw"
|
||||
|
||||
let zz: Box<WinCondition> = box({ type: 'draw' });
|
||||
>zz : Box<WinCondition>
|
||||
>box({ type: 'draw' }) : Box<{ type: "draw"; }>
|
||||
>box : <T>(value: T) => Box<T>
|
||||
>{ type: 'draw' } : { type: "draw"; }
|
||||
>type : "draw"
|
||||
>'draw' : "draw"
|
||||
|
||||
type WinType = 'win' | 'draw';
|
||||
>WinType : "win" | "draw"
|
||||
|
||||
let yy: Box<WinType> = box('draw');
|
||||
>yy : Box<"win" | "draw">
|
||||
>box('draw') : Box<"draw">
|
||||
>box : <T>(value: T) => Box<T>
|
||||
>'draw' : "draw"
|
||||
|
||||
// Repro from #27074
|
||||
|
||||
interface OK<T> {
|
||||
kind: "OK";
|
||||
>kind : "OK"
|
||||
|
||||
value: T;
|
||||
>value : T
|
||||
}
|
||||
export function ok<T>(value: T): OK<T> {
|
||||
>ok : <T>(value: T) => OK<T>
|
||||
>value : T
|
||||
|
||||
return {
|
||||
>{ kind: "OK", value: value } : { kind: "OK"; value: T; }
|
||||
|
||||
kind: "OK",
|
||||
>kind : "OK"
|
||||
>"OK" : "OK"
|
||||
|
||||
value: value
|
||||
>value : T
|
||||
>value : T
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
let result: OK<[string, number]> = ok(["hello", 12]);
|
||||
>result : OK<[string, number]>
|
||||
>ok(["hello", 12]) : OK<[string, number]>
|
||||
>ok : <T>(value: T) => OK<T>
|
||||
>["hello", 12] : [string, number]
|
||||
>"hello" : "hello"
|
||||
>12 : 12
|
||||
|
||||
// Repro from #25889
|
||||
|
||||
interface I {
|
||||
code: 'mapped',
|
||||
>code : "mapped"
|
||||
|
||||
name: string,
|
||||
>name : string
|
||||
}
|
||||
|
||||
const a3: I[] = ['a', 'b'].map(name => {
|
||||
>a3 : I[]
|
||||
>['a', 'b'].map(name => { return { code: 'mapped', name, }}) : { code: "mapped"; name: string; }[]
|
||||
>['a', 'b'].map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>['a', 'b'] : string[]
|
||||
>'a' : "a"
|
||||
>'b' : "b"
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>name => { return { code: 'mapped', name, }} : (name: string) => { code: "mapped"; name: string; }
|
||||
>name : string
|
||||
|
||||
return {
|
||||
>{ code: 'mapped', name, } : { code: "mapped"; name: string; }
|
||||
|
||||
code: 'mapped',
|
||||
>code : "mapped"
|
||||
>'mapped' : "mapped"
|
||||
|
||||
name,
|
||||
>name : string
|
||||
}
|
||||
});
|
||||
|
||||
// Repro from https://www.memsql.com/blog/porting-30k-lines-of-code-from-flow-to-typescript/
|
||||
|
||||
type Player = {
|
||||
>Player : Player
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
age: number;
|
||||
>age : number
|
||||
|
||||
position: "STRIKER" | "GOALKEEPER",
|
||||
>position : "STRIKER" | "GOALKEEPER"
|
||||
|
||||
};
|
||||
|
||||
type F = () => Promise<Array<Player>>;
|
||||
>F : F
|
||||
|
||||
const f1: F = () => {
|
||||
>f1 : F
|
||||
>() => { return Promise.all([ { name: "David Gomes", age: 23, position: "GOALKEEPER", }, { name: "Cristiano Ronaldo", age: 33, position: "STRIKER", } ]);} : () => Promise<[{ name: string; age: number; position: "GOALKEEPER"; }, { name: string; age: number; position: "STRIKER"; }]>
|
||||
|
||||
return Promise.all([
|
||||
>Promise.all([ { name: "David Gomes", age: 23, position: "GOALKEEPER", }, { name: "Cristiano Ronaldo", age: 33, position: "STRIKER", } ]) : Promise<[{ name: string; age: number; position: "GOALKEEPER"; }, { name: string; age: number; position: "STRIKER"; }]>
|
||||
>Promise.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; }
|
||||
>Promise : PromiseConstructor
|
||||
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; }
|
||||
>[ { name: "David Gomes", age: 23, position: "GOALKEEPER", }, { name: "Cristiano Ronaldo", age: 33, position: "STRIKER", } ] : [{ name: string; age: number; position: "GOALKEEPER"; }, { name: string; age: number; position: "STRIKER"; }]
|
||||
{
|
||||
>{ name: "David Gomes", age: 23, position: "GOALKEEPER", } : { name: string; age: number; position: "GOALKEEPER"; }
|
||||
|
||||
name: "David Gomes",
|
||||
>name : string
|
||||
>"David Gomes" : "David Gomes"
|
||||
|
||||
age: 23,
|
||||
>age : number
|
||||
>23 : 23
|
||||
|
||||
position: "GOALKEEPER",
|
||||
>position : "GOALKEEPER"
|
||||
>"GOALKEEPER" : "GOALKEEPER"
|
||||
|
||||
}, {
|
||||
>{ name: "Cristiano Ronaldo", age: 33, position: "STRIKER", } : { name: string; age: number; position: "STRIKER"; }
|
||||
|
||||
name: "Cristiano Ronaldo",
|
||||
>name : string
|
||||
>"Cristiano Ronaldo" : "Cristiano Ronaldo"
|
||||
|
||||
age: 33,
|
||||
>age : number
|
||||
>33 : 33
|
||||
|
||||
position: "STRIKER",
|
||||
>position : "STRIKER"
|
||||
>"STRIKER" : "STRIKER"
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// Breaking change repros from #29478
|
||||
|
||||
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
|
||||
>foldLeft : <U>(z: U, f: (acc: U, t: boolean) => U) => U
|
||||
>z : U
|
||||
>f : (acc: U, t: boolean) => U
|
||||
>acc : U
|
||||
>t : boolean
|
||||
|
||||
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
|
||||
>res : boolean
|
||||
>foldLeft(true, (acc, t) => acc && t) : any
|
||||
>foldLeft : <U>(z: U, f: (acc: U, t: boolean) => U) => U
|
||||
>true : true
|
||||
>(acc, t) => acc && t : (acc: true, t: boolean) => boolean
|
||||
>acc : true
|
||||
>t : boolean
|
||||
>acc && t : boolean
|
||||
>acc : true
|
||||
>t : boolean
|
||||
|
||||
enum State { A, B }
|
||||
>State : State
|
||||
>A : State.A
|
||||
>B : State.B
|
||||
|
||||
type Foo = { state: State }
|
||||
>Foo : Foo
|
||||
>state : State
|
||||
|
||||
declare function bar<T>(f: () => T[]): T[];
|
||||
>bar : <T>(f: () => T[]) => T[]
|
||||
>f : () => T[]
|
||||
|
||||
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
>x : Foo[]
|
||||
>bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]) : any
|
||||
>bar : <T>(f: () => T[]) => T[]
|
||||
>() => !!true ? [{ state: State.A }] : [{ state: State.B }] : () => { state: State.A; }[] | { state: State.B; }[]
|
||||
>!!true ? [{ state: State.A }] : [{ state: State.B }] : { state: State; }[]
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
>[{ state: State.A }] : { state: State; }[]
|
||||
>{ state: State.A } : { state: State; }
|
||||
>state : State
|
||||
>State.A : State.A
|
||||
>State : typeof State
|
||||
>A : State.A
|
||||
>[{ state: State.B }] : { state: State; }[]
|
||||
>{ state: State.B } : { state: State; }
|
||||
>state : State
|
||||
>State.B : State.B
|
||||
>State : typeof State
|
||||
>B : State.B
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
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'.
|
||||
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(38,25): error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(39,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(47,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(48,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(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(82,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(74,12): 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 TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,41): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,51): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(76,15): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(76,15): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(76,43): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(76,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(83,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(144,40): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(145,40): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'.
|
||||
Type 'T' is not assignable to type 'symbol'.
|
||||
|
||||
|
||||
@@ -54,22 +54,23 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322:
|
||||
type T16 = ReturnType<never>; // never
|
||||
type T17 = ReturnType<string>; // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint '(...args: any[]) => 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'.
|
||||
!!! 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 T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
type U11 = InstanceType<any>; // any
|
||||
type U12 = InstanceType<never>; // never
|
||||
type U13 = InstanceType<string>; // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
!!! 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'.
|
||||
!!! 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;
|
||||
|
||||
@@ -226,4 +227,14 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(144,40): error TS2322:
|
||||
|
||||
type Test1 = EnsureIsString<"hello">; // "hello"
|
||||
type Test2 = EnsureIsString<42>; // never
|
||||
|
||||
// Repros from #26856
|
||||
|
||||
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
|
||||
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
|
||||
}
|
||||
|
||||
const result = invoker('test', true)({ test: (a: boolean) => 123 })
|
||||
|
||||
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
|
||||
|
||||
@@ -31,6 +31,7 @@ type T15 = ReturnType<any>; // any
|
||||
type T16 = ReturnType<never>; // never
|
||||
type T17 = ReturnType<string>; // Error
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
type U11 = InstanceType<any>; // any
|
||||
@@ -166,6 +167,16 @@ type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
|
||||
|
||||
type Test1 = EnsureIsString<"hello">; // "hello"
|
||||
type Test2 = EnsureIsString<42>; // never
|
||||
|
||||
// Repros from #26856
|
||||
|
||||
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
|
||||
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
|
||||
}
|
||||
|
||||
const result = invoker('test', true)({ test: (a: boolean) => 123 })
|
||||
|
||||
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
|
||||
|
||||
|
||||
//// [inferTypes1.js]
|
||||
@@ -182,3 +193,12 @@ var C = /** @class */ (function () {
|
||||
}());
|
||||
var z1 = ex.customClass;
|
||||
var z2 = ex.obj.nested.attr;
|
||||
// Repros from #26856
|
||||
function invoker(key) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
return function (obj) { return obj[key].apply(obj, args); };
|
||||
}
|
||||
var result = invoker('test', true)({ test: function (a) { return 123; } });
|
||||
@@ -119,575 +119,624 @@ type T18 = ReturnType<Function>; // Error
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
|
||||
>T19 : Symbol(T19, Decl(inferTypes1.ts, 31, 32))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 32, 9))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 32, 40))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 32, 50))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 32, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 32, 9))
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
>U10 : Symbol(U10, Decl(inferTypes1.ts, 31, 32))
|
||||
>U10 : Symbol(U10, Decl(inferTypes1.ts, 32, 71))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 16, 1))
|
||||
|
||||
type U11 = InstanceType<any>; // any
|
||||
>U11 : Symbol(U11, Decl(inferTypes1.ts, 33, 34))
|
||||
>U11 : Symbol(U11, Decl(inferTypes1.ts, 34, 34))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type U12 = InstanceType<never>; // never
|
||||
>U12 : Symbol(U12, Decl(inferTypes1.ts, 34, 29))
|
||||
>U12 : Symbol(U12, Decl(inferTypes1.ts, 35, 29))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type U13 = InstanceType<string>; // Error
|
||||
>U13 : Symbol(U13, Decl(inferTypes1.ts, 35, 31))
|
||||
>U13 : Symbol(U13, Decl(inferTypes1.ts, 36, 31))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
>U14 : Symbol(U14, Decl(inferTypes1.ts, 36, 32))
|
||||
>U14 : Symbol(U14, Decl(inferTypes1.ts, 37, 32))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
>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))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 40, 18))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 40, 29))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 40, 18))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 40, 58))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 40, 66))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 40, 66))
|
||||
|
||||
type T20 = ArgumentType<() => void>; // {}
|
||||
>T20 : Symbol(T20, Decl(inferTypes1.ts, 39, 87))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T20 : Symbol(T20, Decl(inferTypes1.ts, 40, 87))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
|
||||
type T21 = ArgumentType<(x: string) => number>; // string
|
||||
>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, 42, 47))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T21 : Symbol(T21, Decl(inferTypes1.ts, 42, 36))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 43, 25))
|
||||
|
||||
type T22 = ArgumentType<(x?: string) => number>; // string | undefined
|
||||
>T22 : Symbol(T22, Decl(inferTypes1.ts, 43, 47))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 44, 25))
|
||||
|
||||
type T23 = ArgumentType<(...args: string[]) => number>; // string
|
||||
>T23 : Symbol(T23, Decl(inferTypes1.ts, 43, 48))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 44, 25))
|
||||
>T23 : Symbol(T23, Decl(inferTypes1.ts, 44, 48))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 45, 25))
|
||||
|
||||
type T24 = ArgumentType<(x: string, y: string) => number>; // Error
|
||||
>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))
|
||||
>T24 : Symbol(T24, Decl(inferTypes1.ts, 45, 55))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 46, 25))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 46, 35))
|
||||
|
||||
type T25 = ArgumentType<Function>; // Error
|
||||
>T25 : Symbol(T25, Decl(inferTypes1.ts, 45, 58))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T25 : Symbol(T25, Decl(inferTypes1.ts, 46, 58))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type T26 = ArgumentType<any>; // any
|
||||
>T26 : Symbol(T26, Decl(inferTypes1.ts, 46, 34))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T26 : Symbol(T26, Decl(inferTypes1.ts, 47, 34))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 34))
|
||||
|
||||
type T27 = ArgumentType<never>; // never
|
||||
>T27 : Symbol(T27, Decl(inferTypes1.ts, 47, 29))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T27 : Symbol(T27, Decl(inferTypes1.ts, 48, 29))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 38, 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, 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))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 49, 31))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 51, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 51, 19))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 51, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 51, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 51, 51))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 51, 60))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 51, 63))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 51, 72))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 51, 60))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 51, 72))
|
||||
|
||||
type T30 = X1<{ x: any, y: any }>; // [any, any]
|
||||
>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))
|
||||
>T30 : Symbol(T30, Decl(inferTypes1.ts, 51, 92))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 49, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 53, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 53, 23))
|
||||
|
||||
type T31 = X1<{ x: number, y: string }>; // [number, string]
|
||||
>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, 53, 40))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 48, 31))
|
||||
>T31 : Symbol(T31, Decl(inferTypes1.ts, 53, 34))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 49, 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 T32 = X1<{ x: number, y: string, z: boolean }>; // [number, string]
|
||||
>T32 : Symbol(T32, Decl(inferTypes1.ts, 54, 40))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 49, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 55, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 55, 26))
|
||||
>z : Symbol(z, Decl(inferTypes1.ts, 55, 37))
|
||||
|
||||
type X2<T> = T extends { a: infer U, b: infer U } ? U : never;
|
||||
>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))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 57, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 57, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 57, 24))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 57, 33), Decl(inferTypes1.ts, 57, 45))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 57, 36))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 57, 33), Decl(inferTypes1.ts, 57, 45))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 57, 33), Decl(inferTypes1.ts, 57, 45))
|
||||
|
||||
type T40 = X2<{}>; // never
|
||||
>T40 : Symbol(T40, Decl(inferTypes1.ts, 56, 62))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>T40 : Symbol(T40, Decl(inferTypes1.ts, 57, 62))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 52))
|
||||
|
||||
type T41 = X2<{ a: string }>; // never
|
||||
>T41 : Symbol(T41, Decl(inferTypes1.ts, 58, 18))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 59, 15))
|
||||
>T41 : Symbol(T41, Decl(inferTypes1.ts, 59, 18))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 60, 15))
|
||||
|
||||
type T42 = X2<{ a: string, b: string }>; // string
|
||||
>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, 60, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>T42 : Symbol(T42, Decl(inferTypes1.ts, 60, 29))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 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, 61, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
type T43 = X2<{ a: number, b: string }>; // string | number
|
||||
>T43 : Symbol(T43, Decl(inferTypes1.ts, 61, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 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 T44 = X2<{ a: number, b: string, c: boolean }>; // string | number
|
||||
>T44 : Symbol(T44, Decl(inferTypes1.ts, 62, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 55, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 63, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 63, 26))
|
||||
>c : Symbol(c, Decl(inferTypes1.ts, 63, 37))
|
||||
|
||||
type X3<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;
|
||||
>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))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 65, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 65, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 65, 24))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 65, 29))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 65, 37), Decl(inferTypes1.ts, 65, 62))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 65, 49))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 65, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 65, 37), Decl(inferTypes1.ts, 65, 62))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 65, 37), Decl(inferTypes1.ts, 65, 62))
|
||||
|
||||
type T50 = X3<{}>; // never
|
||||
>T50 : Symbol(T50, Decl(inferTypes1.ts, 64, 88))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>T50 : Symbol(T50, Decl(inferTypes1.ts, 65, 88))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 52))
|
||||
|
||||
type T51 = X3<{ a: (x: string) => void }>; // never
|
||||
>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))
|
||||
|
||||
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))
|
||||
>T51 : Symbol(T51, Decl(inferTypes1.ts, 67, 18))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 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))
|
||||
type T52 = X3<{ a: (x: string) => void, b: (x: string) => void }>; // string
|
||||
>T52 : Symbol(T52, Decl(inferTypes1.ts, 68, 42))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 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))
|
||||
type T53 = X3<{ a: (x: number) => void, b: (x: string) => void }>; // string & number
|
||||
>T53 : Symbol(T53, Decl(inferTypes1.ts, 69, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 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))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 70, 44))
|
||||
|
||||
type T54 = X3<{ a: (x: number) => void, b: () => void }>; // number
|
||||
>T54 : Symbol(T54, Decl(inferTypes1.ts, 70, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 63, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 71, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 71, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 71, 39))
|
||||
|
||||
type T60 = infer U; // Error
|
||||
>T60 : Symbol(T60, Decl(inferTypes1.ts, 70, 57))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 72, 16))
|
||||
>T60 : Symbol(T60, Decl(inferTypes1.ts, 71, 57))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 73, 16))
|
||||
|
||||
type T61<T> = infer A extends infer B ? infer C : infer D; // Error
|
||||
>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))
|
||||
>T61 : Symbol(T61, Decl(inferTypes1.ts, 73, 19))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 74, 9))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 74, 19))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 74, 35))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 74, 45))
|
||||
>D : Symbol(D, Decl(inferTypes1.ts, 74, 55))
|
||||
|
||||
type T62<T> = U extends (infer U)[] ? U : U; // Error
|
||||
>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))
|
||||
>T62 : Symbol(T62, Decl(inferTypes1.ts, 74, 58))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 75, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 75, 30))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 75, 30))
|
||||
|
||||
type T63<T> = T extends (infer A extends infer B ? infer C : infer D) ? string : number;
|
||||
>T63 : Symbol(T63, Decl(inferTypes1.ts, 74, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 75, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 75, 9))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 75, 30))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 75, 46))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 75, 56))
|
||||
>D : Symbol(D, Decl(inferTypes1.ts, 75, 66))
|
||||
>T63 : Symbol(T63, Decl(inferTypes1.ts, 75, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 76, 30))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 76, 46))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 76, 56))
|
||||
>D : Symbol(D, Decl(inferTypes1.ts, 76, 66))
|
||||
|
||||
type T70<T extends string> = { x: T };
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 75, 88))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 77, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 76, 88))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 78, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 78, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 78, 9))
|
||||
|
||||
type T71<T> = T extends T70<infer U> ? T70<U> : never;
|
||||
>T71 : Symbol(T71, Decl(inferTypes1.ts, 77, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 78, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 78, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 75, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 78, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 75, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 78, 33))
|
||||
>T71 : Symbol(T71, Decl(inferTypes1.ts, 78, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 76, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 79, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 76, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 79, 33))
|
||||
|
||||
type T72<T extends number> = { y: T };
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 78, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 80, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 79, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 81, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 81, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 81, 9))
|
||||
|
||||
type T73<T> = T extends T72<infer U> ? T70<U> : never; // Error
|
||||
>T73 : Symbol(T73, Decl(inferTypes1.ts, 80, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 81, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 81, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 78, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 81, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 75, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 81, 33))
|
||||
>T73 : Symbol(T73, Decl(inferTypes1.ts, 81, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 79, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 82, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 76, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 82, 33))
|
||||
|
||||
type T74<T extends number, U extends string> = { x: T, y: U };
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 81, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 26))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 83, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 83, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 26))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 82, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 26))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 84, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 84, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 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, 83, 62))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 81, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 75, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 78, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 81, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T75 : Symbol(T75, Decl(inferTypes1.ts, 84, 62))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 82, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 76, 88))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 79, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 82, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 33), Decl(inferTypes1.ts, 85, 42))
|
||||
|
||||
type T76<T extends T[], U extends T> = { x: T };
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 84, 84))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 86, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 86, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 85, 84))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 87, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 87, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
|
||||
type T77<T> = T extends T76<infer X, infer Y> ? T76<X, Y> : never;
|
||||
>T77 : Symbol(T77, Decl(inferTypes1.ts, 86, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 84, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 87, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 84, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 87, 42))
|
||||
>T77 : Symbol(T77, Decl(inferTypes1.ts, 87, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 85, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 88, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 85, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 88, 42))
|
||||
|
||||
type T78<T> = T extends T76<infer X, infer X> ? T76<X, X> : never;
|
||||
>T78 : Symbol(T78, Decl(inferTypes1.ts, 87, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 84, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33), Decl(inferTypes1.ts, 88, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33), Decl(inferTypes1.ts, 88, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 84, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33), Decl(inferTypes1.ts, 88, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 88, 33), Decl(inferTypes1.ts, 88, 42))
|
||||
>T78 : Symbol(T78, Decl(inferTypes1.ts, 88, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 89, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 89, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 85, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 89, 33), Decl(inferTypes1.ts, 89, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 89, 33), Decl(inferTypes1.ts, 89, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 85, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 89, 33), Decl(inferTypes1.ts, 89, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 89, 33), Decl(inferTypes1.ts, 89, 42))
|
||||
|
||||
type Foo<T extends string, U extends T> = [T, U];
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 88, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 90, 26))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 90, 26))
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 89, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 91, 26))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 91, 26))
|
||||
|
||||
type Bar<T> = T extends Foo<infer X, infer Y> ? Foo<X, Y> : never;
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 9))
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 88, 66))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 91, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 91, 42))
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 88, 66))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 91, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 91, 42))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 92, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 92, 9))
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 89, 66))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 92, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 92, 42))
|
||||
>Foo : Symbol(Foo, Decl(inferTypes1.ts, 89, 66))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 92, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 92, 42))
|
||||
|
||||
type T90 = Bar<[string, string]>; // [string, string]
|
||||
>T90 : Symbol(T90, Decl(inferTypes1.ts, 91, 66))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>T90 : Symbol(T90, Decl(inferTypes1.ts, 92, 66))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
|
||||
type T91 = Bar<[string, "a"]>; // [string, "a"]
|
||||
>T91 : Symbol(T91, Decl(inferTypes1.ts, 93, 33))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>T91 : Symbol(T91, Decl(inferTypes1.ts, 94, 33))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
|
||||
type T92 = Bar<[string, "a"] & { x: string }>; // [string, "a"]
|
||||
>T92 : Symbol(T92, Decl(inferTypes1.ts, 94, 30))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 95, 32))
|
||||
>T92 : Symbol(T92, Decl(inferTypes1.ts, 95, 30))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 96, 32))
|
||||
|
||||
type T93 = Bar<["a", string]>; // never
|
||||
>T93 : Symbol(T93, Decl(inferTypes1.ts, 95, 46))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>T93 : Symbol(T93, Decl(inferTypes1.ts, 96, 46))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
|
||||
type T94 = Bar<[number, number]>; // never
|
||||
>T94 : Symbol(T94, Decl(inferTypes1.ts, 96, 30))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 90, 49))
|
||||
>T94 : Symbol(T94, Decl(inferTypes1.ts, 97, 30))
|
||||
>Bar : Symbol(Bar, Decl(inferTypes1.ts, 91, 49))
|
||||
|
||||
// Example from #21496
|
||||
|
||||
type JsonifiedObject<T extends object> = { [K in keyof T]: Jsonified<T[K]> };
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 97, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 101, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 101, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 101, 21))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 101, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 101, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 101, 44))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 98, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 102, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 102, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 102, 21))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 102, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 102, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 102, 44))
|
||||
|
||||
type Jsonified<T> =
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 101, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 102, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
|
||||
T extends string | number | boolean | null ? T
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
|
||||
: T extends undefined | Function ? never // undefined and functions are removed
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
: T extends { toJSON(): infer R } ? R // toJSON is called if it exists (e.g. Date)
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 106, 17))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 106, 33))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 106, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
>toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 107, 17))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 107, 33))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 107, 33))
|
||||
|
||||
: T extends object ? JsonifiedObject<T>
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 97, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 103, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 98, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 104, 15))
|
||||
|
||||
: "what is this";
|
||||
|
||||
type Example = {
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 108, 21))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 109, 21))
|
||||
|
||||
str: "literalstring",
|
||||
>str : Symbol(str, Decl(inferTypes1.ts, 110, 16))
|
||||
>str : Symbol(str, Decl(inferTypes1.ts, 111, 16))
|
||||
|
||||
fn: () => void,
|
||||
>fn : Symbol(fn, Decl(inferTypes1.ts, 111, 25))
|
||||
>fn : Symbol(fn, Decl(inferTypes1.ts, 112, 25))
|
||||
|
||||
date: Date,
|
||||
>date : Symbol(date, Decl(inferTypes1.ts, 112, 19))
|
||||
>date : Symbol(date, Decl(inferTypes1.ts, 113, 19))
|
||||
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
|
||||
|
||||
customClass: MyClass,
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 113, 15))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 120, 1))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 114, 15))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 121, 1))
|
||||
|
||||
obj: {
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 114, 25))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 115, 25))
|
||||
|
||||
prop: "property",
|
||||
>prop : Symbol(prop, Decl(inferTypes1.ts, 115, 10))
|
||||
>prop : Symbol(prop, Decl(inferTypes1.ts, 116, 10))
|
||||
|
||||
clz: MyClass,
|
||||
>clz : Symbol(clz, Decl(inferTypes1.ts, 116, 25))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 120, 1))
|
||||
>clz : Symbol(clz, Decl(inferTypes1.ts, 117, 25))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 121, 1))
|
||||
|
||||
nested: { attr: Date }
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 117, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 118, 17))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 118, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 119, 17))
|
||||
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
declare class MyClass {
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 120, 1))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 121, 1))
|
||||
|
||||
toJSON(): "correct";
|
||||
>toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 122, 23))
|
||||
>toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 123, 23))
|
||||
}
|
||||
|
||||
type JsonifiedExample = Jsonified<Example>;
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 124, 1))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 101, 77))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 108, 21))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 125, 1))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 102, 77))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 109, 21))
|
||||
|
||||
declare let ex: JsonifiedExample;
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 127, 11))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 124, 1))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 128, 11))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 125, 1))
|
||||
|
||||
const z1: "correct" = ex.customClass;
|
||||
>z1 : Symbol(z1, Decl(inferTypes1.ts, 128, 5))
|
||||
>ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 113, 15))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 127, 11))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 113, 15))
|
||||
>z1 : Symbol(z1, Decl(inferTypes1.ts, 129, 5))
|
||||
>ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 114, 15))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 128, 11))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 114, 15))
|
||||
|
||||
const z2: string = ex.obj.nested.attr;
|
||||
>z2 : Symbol(z2, Decl(inferTypes1.ts, 129, 5))
|
||||
>ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 118, 17))
|
||||
>ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 117, 21))
|
||||
>ex.obj : Symbol(obj, Decl(inferTypes1.ts, 114, 25))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 127, 11))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 114, 25))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 117, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 118, 17))
|
||||
>z2 : Symbol(z2, Decl(inferTypes1.ts, 130, 5))
|
||||
>ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 119, 17))
|
||||
>ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 118, 21))
|
||||
>ex.obj : Symbol(obj, Decl(inferTypes1.ts, 115, 25))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 128, 11))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 115, 25))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 118, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 119, 17))
|
||||
|
||||
// Repros from #21631
|
||||
|
||||
type A1<T, U extends A1<any, any>> = [T, U];
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 129, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 133, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 129, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 133, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 130, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 134, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 134, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 130, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 134, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 134, 10))
|
||||
|
||||
type B1<S> = S extends A1<infer T, infer U> ? [T, U] : never;
|
||||
>B1 : Symbol(B1, Decl(inferTypes1.ts, 133, 44))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 134, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 134, 8))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 129, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 134, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 134, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 134, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 134, 40))
|
||||
>B1 : Symbol(B1, Decl(inferTypes1.ts, 134, 44))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 135, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 135, 8))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 130, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 135, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 135, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 135, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 135, 40))
|
||||
|
||||
type A2<T, U extends void> = [T, U];
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 134, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 136, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 136, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 136, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 136, 10))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 135, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 137, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 137, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 137, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 137, 10))
|
||||
|
||||
type B2<S> = S extends A2<infer T, infer U> ? [T, U] : never;
|
||||
>B2 : Symbol(B2, Decl(inferTypes1.ts, 136, 36))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 137, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 137, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 134, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 137, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 137, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 137, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 137, 40))
|
||||
>B2 : Symbol(B2, Decl(inferTypes1.ts, 137, 36))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 138, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 138, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 135, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 138, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 138, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 138, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 138, 40))
|
||||
|
||||
type C2<S, U extends void> = S extends A2<infer T, U> ? [T, U] : never;
|
||||
>C2 : Symbol(C2, Decl(inferTypes1.ts, 137, 61))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 138, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 138, 10))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 138, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 134, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 138, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 138, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 138, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 138, 10))
|
||||
>C2 : Symbol(C2, Decl(inferTypes1.ts, 138, 61))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 139, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 139, 10))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 139, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 135, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 139, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 139, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 139, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 139, 10))
|
||||
|
||||
// Repro from #21735
|
||||
|
||||
type A<T> = T extends string ? { [P in T]: void; } : T;
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 138, 71))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 142, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 142, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 142, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 142, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 142, 7))
|
||||
|
||||
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 142, 55))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 139, 71))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 143, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 143, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 143, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 143, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 143, 7))
|
||||
|
||||
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 143, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 144, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 144, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 144, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 144, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 144, 7))
|
||||
|
||||
// Repro from #22302
|
||||
|
||||
type MatchingKeys<T, U, K extends keyof T = keyof T> =
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 143, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 147, 18))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 147, 20))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 147, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 147, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 147, 18))
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 144, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 148, 18))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 148, 20))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 148, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 148, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 148, 18))
|
||||
|
||||
K extends keyof T ? T[K] extends U ? K : never : never;
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 147, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 147, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 147, 18))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 147, 23))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 147, 20))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 147, 23))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 148, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 148, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 148, 18))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 148, 23))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 148, 20))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 148, 23))
|
||||
|
||||
type VoidKeys<T> = MatchingKeys<T, void>;
|
||||
>VoidKeys : Symbol(VoidKeys, Decl(inferTypes1.ts, 148, 59))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 150, 14))
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 143, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 150, 14))
|
||||
>VoidKeys : Symbol(VoidKeys, Decl(inferTypes1.ts, 149, 59))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 151, 14))
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 144, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 151, 14))
|
||||
|
||||
interface test {
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 150, 41))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 151, 41))
|
||||
|
||||
a: 1,
|
||||
>a : Symbol(test.a, Decl(inferTypes1.ts, 152, 16))
|
||||
>a : Symbol(test.a, Decl(inferTypes1.ts, 153, 16))
|
||||
|
||||
b: void
|
||||
>b : Symbol(test.b, Decl(inferTypes1.ts, 153, 9))
|
||||
>b : Symbol(test.b, Decl(inferTypes1.ts, 154, 9))
|
||||
}
|
||||
|
||||
type T80 = MatchingKeys<test, void>;
|
||||
>T80 : Symbol(T80, Decl(inferTypes1.ts, 155, 1))
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 143, 55))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 150, 41))
|
||||
>T80 : Symbol(T80, Decl(inferTypes1.ts, 156, 1))
|
||||
>MatchingKeys : Symbol(MatchingKeys, Decl(inferTypes1.ts, 144, 55))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 151, 41))
|
||||
|
||||
type T81 = VoidKeys<test>;
|
||||
>T81 : Symbol(T81, Decl(inferTypes1.ts, 157, 36))
|
||||
>VoidKeys : Symbol(VoidKeys, Decl(inferTypes1.ts, 148, 59))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 150, 41))
|
||||
>T81 : Symbol(T81, Decl(inferTypes1.ts, 158, 36))
|
||||
>VoidKeys : Symbol(VoidKeys, Decl(inferTypes1.ts, 149, 59))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 151, 41))
|
||||
|
||||
// Repro from #22221
|
||||
|
||||
type MustBeString<T extends string> = T;
|
||||
>MustBeString : Symbol(MustBeString, Decl(inferTypes1.ts, 158, 26))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 162, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 162, 18))
|
||||
>MustBeString : Symbol(MustBeString, Decl(inferTypes1.ts, 159, 26))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 163, 18))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 163, 18))
|
||||
|
||||
type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 162, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 163, 20))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 163, 20))
|
||||
>MustBeString : Symbol(MustBeString, Decl(inferTypes1.ts, 158, 26))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 163, 53))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 163, 53))
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 163, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 164, 20))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 164, 20))
|
||||
>MustBeString : Symbol(MustBeString, Decl(inferTypes1.ts, 159, 26))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 164, 53))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 164, 53))
|
||||
|
||||
type Test1 = EnsureIsString<"hello">; // "hello"
|
||||
>Test1 : Symbol(Test1, Decl(inferTypes1.ts, 163, 69))
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 162, 40))
|
||||
>Test1 : Symbol(Test1, Decl(inferTypes1.ts, 164, 69))
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 163, 40))
|
||||
|
||||
type Test2 = EnsureIsString<42>; // never
|
||||
>Test2 : Symbol(Test2, Decl(inferTypes1.ts, 165, 37))
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 162, 40))
|
||||
>Test2 : Symbol(Test2, Decl(inferTypes1.ts, 166, 37))
|
||||
>EnsureIsString : Symbol(EnsureIsString, Decl(inferTypes1.ts, 163, 40))
|
||||
|
||||
// Repros from #26856
|
||||
|
||||
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
|
||||
>invoker : Symbol(invoker, Decl(inferTypes1.ts, 167, 32))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 171, 18))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 171, 53))
|
||||
>key : Symbol(key, Decl(inferTypes1.ts, 171, 72))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 171, 18))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 171, 79))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 171, 53))
|
||||
|
||||
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 172, 12))
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 171, 18))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 172, 33))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 171, 53))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 172, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 172, 12))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 172, 12))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 171, 18))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 172, 55))
|
||||
>key : Symbol(key, Decl(inferTypes1.ts, 171, 72))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 171, 79))
|
||||
}
|
||||
|
||||
const result = invoker('test', true)({ test: (a: boolean) => 123 })
|
||||
>result : Symbol(result, Decl(inferTypes1.ts, 175, 5))
|
||||
>invoker : Symbol(invoker, Decl(inferTypes1.ts, 167, 32))
|
||||
>test : Symbol(test, Decl(inferTypes1.ts, 175, 38))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 175, 46))
|
||||
|
||||
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
|
||||
>Foo2 : Symbol(Foo2, Decl(inferTypes1.ts, 175, 67))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 177, 10))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 177, 41))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 177, 10))
|
||||
|
||||
@@ -83,6 +83,11 @@ type T17 = ReturnType<string>; // Error
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
>T18 : any
|
||||
|
||||
type T19<T extends any[]> = ReturnType<(x: string, ...args: T) => T[]>; // T[]
|
||||
>T19 : T[]
|
||||
>x : string
|
||||
>args : T
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
>U10 : C
|
||||
>C : typeof C
|
||||
@@ -426,3 +431,39 @@ type Test1 = EnsureIsString<"hello">; // "hello"
|
||||
type Test2 = EnsureIsString<42>; // never
|
||||
>Test2 : never
|
||||
|
||||
// Repros from #26856
|
||||
|
||||
function invoker <K extends string | number | symbol, A extends any[]> (key: K, ...args: A) {
|
||||
>invoker : <K extends string | number | symbol, A extends any[]>(key: K, ...args: A) => <T extends Record<K, (...args: A) => any>>(obj: T) => ReturnType<T[K]>
|
||||
>key : K
|
||||
>args : A
|
||||
|
||||
return <T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args)
|
||||
><T extends Record<K, (...args: A) => any>> (obj: T): ReturnType<T[K]> => obj[key](...args) : <T extends Record<K, (...args: A) => any>>(obj: T) => ReturnType<T[K]>
|
||||
>args : A
|
||||
>obj : T
|
||||
>obj[key](...args) : any
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
>...args : any
|
||||
>args : A
|
||||
}
|
||||
|
||||
const result = invoker('test', true)({ test: (a: boolean) => 123 })
|
||||
>result : number
|
||||
>invoker('test', true)({ test: (a: boolean) => 123 }) : number
|
||||
>invoker('test', true) : <T extends Record<"test", (args_0: boolean) => any>>(obj: T) => ReturnType<T["test"]>
|
||||
>invoker : <K extends string | number | symbol, A extends any[]>(key: K, ...args: A) => <T extends Record<K, (...args: A) => any>>(obj: T) => ReturnType<T[K]>
|
||||
>'test' : "test"
|
||||
>true : true
|
||||
>{ test: (a: boolean) => 123 } : { test: (a: boolean) => number; }
|
||||
>test : (a: boolean) => number
|
||||
>(a: boolean) => 123 : (a: boolean) => number
|
||||
>a : boolean
|
||||
>123 : 123
|
||||
|
||||
type Foo2<A extends any[]> = ReturnType<(...args: A) => string>;
|
||||
>Foo2 : string
|
||||
>args : A
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [inferenceAndSelfReferentialConstraint.ts]
|
||||
// @strict
|
||||
|
||||
// Repro from #29520
|
||||
|
||||
type Test<K extends keyof any> = {
|
||||
[P in K | "foo"]: P extends "foo" ? true : () => any
|
||||
}
|
||||
|
||||
function test<T extends Test<keyof T>>(arg: T) {
|
||||
return arg;
|
||||
}
|
||||
|
||||
const res1 = test({
|
||||
foo: true,
|
||||
bar() {
|
||||
}
|
||||
});
|
||||
|
||||
const res2 = test({
|
||||
foo: true,
|
||||
bar: function () {
|
||||
}
|
||||
});
|
||||
|
||||
const res3 = test({
|
||||
foo: true,
|
||||
bar: () => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//// [inferenceAndSelfReferentialConstraint.js]
|
||||
// @strict
|
||||
function test(arg) {
|
||||
return arg;
|
||||
}
|
||||
var res1 = test({
|
||||
foo: true,
|
||||
bar: function () {
|
||||
}
|
||||
});
|
||||
var res2 = test({
|
||||
foo: true,
|
||||
bar: function () {
|
||||
}
|
||||
});
|
||||
var res3 = test({
|
||||
foo: true,
|
||||
bar: function () {
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
=== tests/cases/compiler/inferenceAndSelfReferentialConstraint.ts ===
|
||||
// @strict
|
||||
|
||||
// Repro from #29520
|
||||
|
||||
type Test<K extends keyof any> = {
|
||||
>Test : Symbol(Test, Decl(inferenceAndSelfReferentialConstraint.ts, 0, 0))
|
||||
>K : Symbol(K, Decl(inferenceAndSelfReferentialConstraint.ts, 4, 10))
|
||||
|
||||
[P in K | "foo"]: P extends "foo" ? true : () => any
|
||||
>P : Symbol(P, Decl(inferenceAndSelfReferentialConstraint.ts, 5, 3))
|
||||
>K : Symbol(K, Decl(inferenceAndSelfReferentialConstraint.ts, 4, 10))
|
||||
>P : Symbol(P, Decl(inferenceAndSelfReferentialConstraint.ts, 5, 3))
|
||||
}
|
||||
|
||||
function test<T extends Test<keyof T>>(arg: T) {
|
||||
>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1))
|
||||
>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14))
|
||||
>Test : Symbol(Test, Decl(inferenceAndSelfReferentialConstraint.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14))
|
||||
>arg : Symbol(arg, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 39))
|
||||
>T : Symbol(T, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 14))
|
||||
|
||||
return arg;
|
||||
>arg : Symbol(arg, Decl(inferenceAndSelfReferentialConstraint.ts, 8, 39))
|
||||
}
|
||||
|
||||
const res1 = test({
|
||||
>res1 : Symbol(res1, Decl(inferenceAndSelfReferentialConstraint.ts, 12, 5))
|
||||
>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1))
|
||||
|
||||
foo: true,
|
||||
>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 12, 19))
|
||||
|
||||
bar() {
|
||||
>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 13, 12))
|
||||
}
|
||||
});
|
||||
|
||||
const res2 = test({
|
||||
>res2 : Symbol(res2, Decl(inferenceAndSelfReferentialConstraint.ts, 18, 5))
|
||||
>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1))
|
||||
|
||||
foo: true,
|
||||
>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 18, 19))
|
||||
|
||||
bar: function () {
|
||||
>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 19, 12))
|
||||
}
|
||||
});
|
||||
|
||||
const res3 = test({
|
||||
>res3 : Symbol(res3, Decl(inferenceAndSelfReferentialConstraint.ts, 24, 5))
|
||||
>test : Symbol(test, Decl(inferenceAndSelfReferentialConstraint.ts, 6, 1))
|
||||
|
||||
foo: true,
|
||||
>foo : Symbol(foo, Decl(inferenceAndSelfReferentialConstraint.ts, 24, 19))
|
||||
|
||||
bar: () => {
|
||||
>bar : Symbol(bar, Decl(inferenceAndSelfReferentialConstraint.ts, 25, 12))
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
=== tests/cases/compiler/inferenceAndSelfReferentialConstraint.ts ===
|
||||
// @strict
|
||||
|
||||
// Repro from #29520
|
||||
|
||||
type Test<K extends keyof any> = {
|
||||
>Test : Test<K>
|
||||
|
||||
[P in K | "foo"]: P extends "foo" ? true : () => any
|
||||
>true : true
|
||||
}
|
||||
|
||||
function test<T extends Test<keyof T>>(arg: T) {
|
||||
>test : <T extends Test<keyof T>>(arg: T) => T
|
||||
>arg : T
|
||||
|
||||
return arg;
|
||||
>arg : T
|
||||
}
|
||||
|
||||
const res1 = test({
|
||||
>res1 : { foo: true; bar(): void; }
|
||||
>test({ foo: true, bar() { }}) : { foo: true; bar(): void; }
|
||||
>test : <T extends Test<keyof T>>(arg: T) => T
|
||||
>{ foo: true, bar() { }} : { foo: true; bar(): void; }
|
||||
|
||||
foo: true,
|
||||
>foo : true
|
||||
>true : true
|
||||
|
||||
bar() {
|
||||
>bar : () => void
|
||||
}
|
||||
});
|
||||
|
||||
const res2 = test({
|
||||
>res2 : { foo: true; bar: () => void; }
|
||||
>test({ foo: true, bar: function () { }}) : { foo: true; bar: () => void; }
|
||||
>test : <T extends Test<keyof T>>(arg: T) => T
|
||||
>{ foo: true, bar: function () { }} : { foo: true; bar: () => void; }
|
||||
|
||||
foo: true,
|
||||
>foo : true
|
||||
>true : true
|
||||
|
||||
bar: function () {
|
||||
>bar : () => void
|
||||
>function () { } : () => void
|
||||
}
|
||||
});
|
||||
|
||||
const res3 = test({
|
||||
>res3 : { foo: true; bar: () => void; }
|
||||
>test({ foo: true, bar: () => { }}) : { foo: true; bar: () => void; }
|
||||
>test : <T extends Test<keyof T>>(arg: T) => T
|
||||
>{ foo: true, bar: () => { }} : { foo: true; bar: () => void; }
|
||||
|
||||
foo: true,
|
||||
>foo : true
|
||||
>true : true
|
||||
|
||||
bar: () => {
|
||||
>bar : () => void
|
||||
>() => { } : () => void
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
tests/cases/compiler/infiniteConstraints.ts(3,37): error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
|
||||
|
||||
==== tests/cases/compiler/infiniteConstraints.ts (4 errors) ====
|
||||
==== tests/cases/compiler/infiniteConstraints.ts (6 errors) ====
|
||||
// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint
|
||||
|
||||
type T1<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { val: string }>["val"] }> = B;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
type T2<B extends { [K in keyof B]: B[Exclude<keyof B, K>]["val"] }> = B;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
|
||||
@@ -51,4 +55,6 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c
|
||||
declare function function1<T extends {[K in keyof T]: Cond<T[K]>}>(): T[keyof T]["foo"];
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/innerModExport1.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/innerModExport1.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/innerModExport1.ts(5,12): error TS1005: ';' expected.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ tests/cases/compiler/innerModExport1.ts(5,12): error TS1005: ';' expected.
|
||||
var non_export_var: number;
|
||||
module {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
var non_export_var = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/innerModExport2.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
tests/cases/compiler/innerModExport2.ts(5,5): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
tests/cases/compiler/innerModExport2.ts(5,12): error TS1005: ';' expected.
|
||||
tests/cases/compiler/innerModExport2.ts(7,20): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
|
||||
tests/cases/compiler/innerModExport2.ts(13,9): error TS2395: Individual declarations in merged declaration 'export_var' must be all exported or all local.
|
||||
@@ -12,7 +12,7 @@ tests/cases/compiler/innerModExport2.ts(20,7): error TS2339: Property 'NonExport
|
||||
var non_export_var: number;
|
||||
module {
|
||||
~~~~~~
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.
|
||||
!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
var non_export_var = 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ declare function from<T>(): T[];
|
||||
>from : <T>() => T[]
|
||||
|
||||
const c2: ReadonlyArray<A> = from();
|
||||
>c2 : ReadonlyArray<Nominal<"A", string>>
|
||||
>c2 : readonly Nominal<"A", string>[]
|
||||
>from() : Nominal<"A", string>[]
|
||||
>from : <T>() => T[]
|
||||
|
||||
@@ -24,7 +24,7 @@ export function assertIsElement(node: Node | null): node is Element {
|
||||
}
|
||||
|
||||
export function assertNodeTagName<
|
||||
>assertNodeTagName : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>assertNodeTagName : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
|
||||
T extends keyof ElementTagNameMap,
|
||||
U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U {
|
||||
@@ -56,7 +56,7 @@ export function assertNodeTagName<
|
||||
}
|
||||
|
||||
export function assertNodeProperty<
|
||||
>assertNodeProperty : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", P extends keyof ElementTagNameMap[T], V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) => void
|
||||
>assertNodeProperty : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", P extends keyof ElementTagNameMap[T], V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) => void
|
||||
|
||||
T extends keyof ElementTagNameMap,
|
||||
P extends keyof ElementTagNameMap[T],
|
||||
@@ -69,7 +69,7 @@ export function assertNodeProperty<
|
||||
|
||||
if (assertNodeTagName(node, tagName)) {
|
||||
>assertNodeTagName(node, tagName) : boolean
|
||||
>assertNodeTagName : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>assertNodeTagName : <T extends "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>node : Node | null
|
||||
>tagName : T
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export function assertIsElement(node: Node | null): node is Element {
|
||||
}
|
||||
|
||||
export function assertNodeTagName<
|
||||
>assertNodeTagName : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>assertNodeTagName : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
|
||||
T extends keyof ElementTagNameMap,
|
||||
U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U {
|
||||
@@ -70,7 +70,7 @@ export function assertNodeTagName<
|
||||
}
|
||||
|
||||
export function assertNodeProperty<
|
||||
>assertNodeProperty : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", P extends keyof ElementTagNameMap[T], V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) => void
|
||||
>assertNodeProperty : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", P extends keyof ElementTagNameMap[T], V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) => void
|
||||
|
||||
T extends keyof ElementTagNameMap,
|
||||
P extends keyof ElementTagNameMap[T],
|
||||
@@ -83,7 +83,7 @@ export function assertNodeProperty<
|
||||
|
||||
if (assertNodeTagName(node, tagName)) {
|
||||
>assertNodeTagName(node, tagName) : boolean
|
||||
>assertNodeTagName : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>assertNodeTagName : <T extends number | "symbol" | "object" | "a" | "abbr" | "address" | "applet" | "area" | "article" | "aside" | "audio" | "b" | "base" | "basefont" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "dir" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "font" | "footer" | "form" | "frame" | "frameset" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "marquee" | "menu" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "slot" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "tbody" | "td" | "template" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view", U extends ElementTagNameMap[T]>(node: Node | null, tagName: T) => node is U
|
||||
>node : Node | null
|
||||
>tagName : T
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/compiler/file1.ts(1,20): error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
|
||||
tests/cases/compiler/file1.ts(2,16): error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
declare const enum E { X = 1}
|
||||
~
|
||||
!!! error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag is provided.
|
||||
export var y;
|
||||
export var y = E.X;
|
||||
~
|
||||
!!! error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//// [file1.ts]
|
||||
declare const enum E { X = 1}
|
||||
export var y;
|
||||
export var y = E.X;
|
||||
|
||||
|
||||
//// [file1.js]
|
||||
export var y;
|
||||
export var y = E.X;
|
||||
Loaded 100 of 233 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user