mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into baselining
This commit is contained in:
@@ -333,6 +333,8 @@ task("run-eslint-rules-tests").description = "Runs the eslint rule tests";
|
||||
|
||||
const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
|
||||
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
|
||||
|
||||
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
|
||||
const eslint = (folder) => async () => {
|
||||
const ESLINTRC_CI = ".eslintrc.ci.json";
|
||||
const isCIEnv = cmdLineOptions.ci || process.env.CI === "true";
|
||||
|
||||
@@ -6,6 +6,7 @@ interface DiagnosticDetails {
|
||||
code: number;
|
||||
reportsUnnecessary?: {};
|
||||
isEarly?: boolean;
|
||||
elidedInCompatabilityPyramid?: boolean;
|
||||
}
|
||||
|
||||
type InputDiagnosticMessageTable = Map<string, DiagnosticDetails>;
|
||||
@@ -63,14 +64,15 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, inputFil
|
||||
"// generated from '" + inputFilePathRel + "' by '" + thisFilePathRel.replace(/\\/g, "/") + "'\r\n" +
|
||||
"/* @internal */\r\n" +
|
||||
"namespace ts {\r\n" +
|
||||
" function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}): DiagnosticMessage {\r\n" +
|
||||
" return { code, category, key, message, reportsUnnecessary };\r\n" +
|
||||
" function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean): DiagnosticMessage {\r\n" +
|
||||
" return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid };\r\n" +
|
||||
" }\r\n" +
|
||||
" export const Diagnostics = {\r\n";
|
||||
messageTable.forEach(({ code, category, reportsUnnecessary }, name) => {
|
||||
messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid }, name) => {
|
||||
const propName = convertPropertyName(name);
|
||||
const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : "";
|
||||
result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}),\r\n`;
|
||||
const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : "";
|
||||
result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}),\r\n`;
|
||||
});
|
||||
|
||||
result += " };\r\n}";
|
||||
|
||||
Vendored
+6
-1
@@ -76,10 +76,15 @@ declare module "undertaker" {
|
||||
interface TaskFunctionParams {
|
||||
flags?: Record<string, string>;
|
||||
}
|
||||
interface TaskFunctionWrapped {
|
||||
description: string
|
||||
flags: { [name: string]: string }
|
||||
}
|
||||
}
|
||||
|
||||
declare module "gulp-sourcemaps" {
|
||||
interface WriteOptions {
|
||||
destPath?: string;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+39
-15
@@ -564,7 +564,7 @@ namespace ts {
|
||||
if (!isIIFE) {
|
||||
currentFlow = { flags: FlowFlags.Start };
|
||||
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
|
||||
currentFlow.container = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
|
||||
currentFlow.node = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
|
||||
}
|
||||
}
|
||||
// We create a return control flow graph for IIFEs and constructors. For constructors
|
||||
@@ -581,6 +581,7 @@ namespace ts {
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
|
||||
node.flags |= NodeFlags.HasImplicitReturn;
|
||||
if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn;
|
||||
(<FunctionLikeDeclaration>node).endFlowNode = currentFlow;
|
||||
}
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
node.flags |= emitFlags;
|
||||
@@ -671,6 +672,9 @@ namespace ts {
|
||||
bindJSDoc(node);
|
||||
return;
|
||||
}
|
||||
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.WhileStatement:
|
||||
bindWhileStatement(<WhileStatement>node);
|
||||
@@ -708,6 +712,9 @@ namespace ts {
|
||||
case SyntaxKind.CaseClause:
|
||||
bindCaseClause(<CaseClause>node);
|
||||
break;
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
bindExpressionStatement(<ExpressionStatement>node);
|
||||
break;
|
||||
case SyntaxKind.LabeledStatement:
|
||||
bindLabeledStatement(<LabeledStatement>node);
|
||||
break;
|
||||
@@ -845,17 +852,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createBranchLabel(): FlowLabel {
|
||||
return {
|
||||
flags: FlowFlags.BranchLabel,
|
||||
antecedents: undefined
|
||||
};
|
||||
return { flags: FlowFlags.BranchLabel, antecedents: undefined };
|
||||
}
|
||||
|
||||
function createLoopLabel(): FlowLabel {
|
||||
return {
|
||||
flags: FlowFlags.LoopLabel,
|
||||
antecedents: undefined
|
||||
};
|
||||
return { flags: FlowFlags.LoopLabel, antecedents: undefined };
|
||||
}
|
||||
|
||||
function setFlowNodeReferenced(flow: FlowNode) {
|
||||
@@ -885,7 +886,7 @@ namespace ts {
|
||||
return antecedent;
|
||||
}
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return flowNodeCreated({ flags, expression, antecedent });
|
||||
return flowNodeCreated({ flags, antecedent, node: expression });
|
||||
}
|
||||
|
||||
function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode {
|
||||
@@ -893,7 +894,7 @@ namespace ts {
|
||||
return antecedent;
|
||||
}
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return flowNodeCreated({ flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent });
|
||||
return flowNodeCreated({ flags: FlowFlags.SwitchClause, antecedent, switchStatement, clauseStart, clauseEnd });
|
||||
}
|
||||
|
||||
function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode {
|
||||
@@ -901,10 +902,14 @@ namespace ts {
|
||||
return flowNodeCreated({ flags: FlowFlags.Assignment, antecedent, node });
|
||||
}
|
||||
|
||||
function createFlowCall(antecedent: FlowNode, node: CallExpression): FlowNode {
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return flowNodeCreated({ flags: FlowFlags.Call, antecedent, node });
|
||||
}
|
||||
|
||||
function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode {
|
||||
setFlowNodeReferenced(antecedent);
|
||||
const res: FlowArrayMutation = flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node });
|
||||
return res;
|
||||
return flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node });
|
||||
}
|
||||
|
||||
function finishFlowLabel(flow: FlowLabel): FlowNode {
|
||||
@@ -1030,12 +1035,12 @@ namespace ts {
|
||||
function bindForInOrForOfStatement(node: ForInOrOfStatement): void {
|
||||
const preLoopLabel = createLoopLabel();
|
||||
const postLoopLabel = createBranchLabel();
|
||||
bind(node.expression);
|
||||
addAntecedent(preLoopLabel, currentFlow);
|
||||
currentFlow = preLoopLabel;
|
||||
if (node.kind === SyntaxKind.ForOfStatement) {
|
||||
bind(node.awaitModifier);
|
||||
}
|
||||
bind(node.expression);
|
||||
addAntecedent(postLoopLabel, currentFlow);
|
||||
bind(node.initializer);
|
||||
if (node.initializer.kind !== SyntaxKind.VariableDeclarationList) {
|
||||
@@ -1222,7 +1227,8 @@ namespace ts {
|
||||
addAntecedent(postSwitchLabel, currentFlow);
|
||||
const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
|
||||
// We mark a switch statement as possibly exhaustive if it has no default clause and if all
|
||||
// case clauses have unreachable end points (e.g. they all return).
|
||||
// case clauses have unreachable end points (e.g. they all return). Note, we no longer need
|
||||
// this property in control flow analysis, it's there only for backwards compatibility.
|
||||
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
|
||||
if (!hasDefault) {
|
||||
addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
|
||||
@@ -1281,6 +1287,24 @@ namespace ts {
|
||||
activeLabels!.pop();
|
||||
}
|
||||
|
||||
function isDottedName(node: Expression): boolean {
|
||||
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword ||
|
||||
node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression) ||
|
||||
node.kind === SyntaxKind.ParenthesizedExpression && isDottedName((<ParenthesizedExpression>node).expression);
|
||||
}
|
||||
|
||||
function bindExpressionStatement(node: ExpressionStatement): void {
|
||||
bind(node.expression);
|
||||
// A top level call expression with a dotted function name and at least one argument
|
||||
// is potentially an assertion and is therefore included in the control flow.
|
||||
if (node.expression.kind === SyntaxKind.CallExpression) {
|
||||
const call = <CallExpression>node.expression;
|
||||
if (isDottedName(call.expression)) {
|
||||
currentFlow = createFlowCall(currentFlow, call);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindLabeledStatement(node: LabeledStatement): void {
|
||||
const preStatementLabel = createLoopLabel();
|
||||
const postStatementLabel = createBranchLabel();
|
||||
|
||||
@@ -425,7 +425,7 @@ namespace ts {
|
||||
const options = program.getCompilerOptions();
|
||||
forEach(program.getSourceFiles(), f =>
|
||||
program.isSourceFileDefaultLibrary(f) &&
|
||||
!skipTypeChecking(f, options) &&
|
||||
!skipTypeChecking(f, options, program) &&
|
||||
removeSemanticDiagnosticsOf(state, f.path)
|
||||
);
|
||||
}
|
||||
|
||||
+511
-193
File diff suppressed because it is too large
Load Diff
@@ -772,6 +772,12 @@ namespace ts {
|
||||
category: Diagnostics.Advanced_Options,
|
||||
description: Diagnostics.Disable_size_limitations_on_JavaScript_projects
|
||||
},
|
||||
{
|
||||
name: "disableSourceOfProjectReferenceRedirect",
|
||||
type: "boolean",
|
||||
category: Diagnostics.Advanced_Options,
|
||||
description: Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
|
||||
},
|
||||
{
|
||||
name: "noImplicitUseStrict",
|
||||
type: "boolean",
|
||||
|
||||
@@ -1040,6 +1040,35 @@
|
||||
"code": 1357
|
||||
},
|
||||
|
||||
"The types of '{0}' are incompatible between these types.": {
|
||||
"category": "Error",
|
||||
"code": 2200
|
||||
},
|
||||
"The types returned by '{0}' are incompatible between these types.": {
|
||||
"category": "Error",
|
||||
"code": 2201
|
||||
},
|
||||
"Call signature return types '{0}' and '{1}' are incompatible.": {
|
||||
"category": "Error",
|
||||
"code": 2202,
|
||||
"elidedInCompatabilityPyramid": true
|
||||
},
|
||||
"Construct signature return types '{0}' and '{1}' are incompatible.": {
|
||||
"category": "Error",
|
||||
"code": 2203,
|
||||
"elidedInCompatabilityPyramid": true
|
||||
},
|
||||
"Call signatures with no arguments have incompatible return types '{0}' and '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2204,
|
||||
"elidedInCompatabilityPyramid": true
|
||||
},
|
||||
"Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2205,
|
||||
"elidedInCompatabilityPyramid": true
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -4007,6 +4036,10 @@
|
||||
"category": "Message",
|
||||
"code": 6220
|
||||
},
|
||||
"Disable use of source files instead of declaration files from referenced projects.": {
|
||||
"category": "Message",
|
||||
"code": 6221
|
||||
},
|
||||
|
||||
"Projects to reference": {
|
||||
"category": "Message",
|
||||
|
||||
+10
-4
@@ -1946,11 +1946,17 @@ namespace ts {
|
||||
//
|
||||
|
||||
function emitTypePredicate(node: TypePredicateNode) {
|
||||
if (node.assertsModifier) {
|
||||
emit(node.assertsModifier);
|
||||
writeSpace();
|
||||
}
|
||||
emit(node.parameterName);
|
||||
writeSpace();
|
||||
writeKeyword("is");
|
||||
writeSpace();
|
||||
emit(node.type);
|
||||
if (node.type) {
|
||||
writeSpace();
|
||||
writeKeyword("is");
|
||||
writeSpace();
|
||||
emit(node.type);
|
||||
}
|
||||
}
|
||||
|
||||
function emitTypeReference(node: TypeReferenceNode) {
|
||||
|
||||
+12
-2
@@ -669,16 +669,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) {
|
||||
return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type);
|
||||
}
|
||||
|
||||
export function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined) {
|
||||
const node = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode;
|
||||
node.assertsModifier = assertsModifier;
|
||||
node.parameterName = asName(parameterName);
|
||||
node.type = type;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) {
|
||||
return node.parameterName !== parameterName
|
||||
return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type);
|
||||
}
|
||||
|
||||
export function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined) {
|
||||
return node.assertsModifier !== assertsModifier
|
||||
|| node.parameterName !== parameterName
|
||||
|| node.type !== type
|
||||
? updateNode(createTypePredicateNode(parameterName, type), node)
|
||||
? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -165,7 +165,8 @@ namespace ts {
|
||||
return visitNode(cbNode, (<TypeReferenceNode>node).typeName) ||
|
||||
visitNodes(cbNode, cbNodes, (<TypeReferenceNode>node).typeArguments);
|
||||
case SyntaxKind.TypePredicate:
|
||||
return visitNode(cbNode, (<TypePredicateNode>node).parameterName) ||
|
||||
return visitNode(cbNode, (<TypePredicateNode>node).assertsModifier) ||
|
||||
visitNode(cbNode, (<TypePredicateNode>node).parameterName) ||
|
||||
visitNode(cbNode, (<TypePredicateNode>node).type);
|
||||
case SyntaxKind.TypeQuery:
|
||||
return visitNode(cbNode, (<TypeQueryNode>node).exprName);
|
||||
@@ -3041,6 +3042,8 @@ namespace ts {
|
||||
return parseParenthesizedType();
|
||||
case SyntaxKind.ImportKeyword:
|
||||
return parseImportType();
|
||||
case SyntaxKind.AssertsKeyword:
|
||||
return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
|
||||
default:
|
||||
return parseTypeReference();
|
||||
}
|
||||
@@ -3081,6 +3084,7 @@ namespace ts {
|
||||
case SyntaxKind.DotDotDotToken:
|
||||
case SyntaxKind.InferKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
case SyntaxKind.AssertsKeyword:
|
||||
return true;
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
return !inStartOfParameter;
|
||||
@@ -3257,6 +3261,7 @@ namespace ts {
|
||||
const type = parseType();
|
||||
if (typePredicateVariable) {
|
||||
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos);
|
||||
node.assertsModifier = undefined;
|
||||
node.parameterName = typePredicateVariable;
|
||||
node.type = type;
|
||||
return finishNode(node);
|
||||
@@ -3274,6 +3279,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parseAssertsTypePredicate(): TypeNode {
|
||||
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate);
|
||||
node.assertsModifier = parseExpectedToken(SyntaxKind.AssertsKeyword);
|
||||
node.parameterName = token() === SyntaxKind.ThisKeyword ? parseThisTypeNode() : parseIdentifier();
|
||||
node.type = parseOptional(SyntaxKind.IsKeyword) ? parseType() : undefined;
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseType(): TypeNode {
|
||||
// The rules about 'yield' only apply to actual code/expression contexts. They don't
|
||||
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
||||
|
||||
+87
-11
@@ -817,6 +817,8 @@ namespace ts {
|
||||
let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined;
|
||||
let projectReferenceRedirects: Map<ResolvedProjectReference | false> | undefined;
|
||||
let mapFromFileToProjectReferenceRedirects: Map<Path> | undefined;
|
||||
let mapFromToProjectReferenceRedirectSource: Map<SourceOfProjectReferenceRedirect> | undefined;
|
||||
const useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect();
|
||||
|
||||
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
||||
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
|
||||
@@ -831,17 +833,32 @@ namespace ts {
|
||||
if (!resolvedProjectReferences) {
|
||||
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
|
||||
}
|
||||
if (host.setResolvedProjectReferenceCallbacks) {
|
||||
host.setResolvedProjectReferenceCallbacks({
|
||||
getSourceOfProjectReferenceRedirect,
|
||||
forEachResolvedProjectReference
|
||||
});
|
||||
}
|
||||
if (rootNames.length) {
|
||||
for (const parsedRef of resolvedProjectReferences) {
|
||||
if (!parsedRef) continue;
|
||||
const out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
|
||||
if (out) {
|
||||
processSourceFile(changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
if (useSourceOfProjectReferenceRedirect) {
|
||||
if (out || getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) {
|
||||
for (const fileName of parsedRef.commandLine.fileNames) {
|
||||
processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) {
|
||||
for (const fileName of parsedRef.commandLine.fileNames) {
|
||||
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
|
||||
processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
else {
|
||||
if (out) {
|
||||
processSourceFile(changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
}
|
||||
else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) {
|
||||
for (const fileName of parsedRef.commandLine.fileNames) {
|
||||
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
|
||||
processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -955,6 +972,7 @@ namespace ts {
|
||||
getResolvedProjectReferenceToRedirect,
|
||||
getResolvedProjectReferenceByPath,
|
||||
forEachResolvedProjectReference,
|
||||
isSourceOfProjectReferenceRedirect,
|
||||
emitBuildInfo
|
||||
};
|
||||
|
||||
@@ -987,9 +1005,15 @@ namespace ts {
|
||||
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
}
|
||||
|
||||
function isValidSourceFileForEmit(file: SourceFile) {
|
||||
// source file is allowed to be emitted and its not source of project reference redirect
|
||||
return sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) &&
|
||||
!isSourceOfProjectReferenceRedirect(file.fileName);
|
||||
}
|
||||
|
||||
function getCommonSourceDirectory() {
|
||||
if (commonSourceDirectory === undefined) {
|
||||
const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect));
|
||||
const emittedFiles = filter(files, file => isValidSourceFileForEmit(file));
|
||||
if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
|
||||
// If a rootDir is specified use it as the commonSourceDirectory
|
||||
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory);
|
||||
@@ -1220,6 +1244,12 @@ namespace ts {
|
||||
}
|
||||
if (projectReferences) {
|
||||
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
|
||||
if (host.setResolvedProjectReferenceCallbacks) {
|
||||
host.setResolvedProjectReferenceCallbacks({
|
||||
getSourceOfProjectReferenceRedirect,
|
||||
forEachResolvedProjectReference
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
@@ -1403,6 +1433,13 @@ namespace ts {
|
||||
for (const newSourceFile of newSourceFiles) {
|
||||
const filePath = newSourceFile.path;
|
||||
addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath);
|
||||
if (useSourceOfProjectReferenceRedirect) {
|
||||
const redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName);
|
||||
if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) {
|
||||
const redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName);
|
||||
addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined);
|
||||
}
|
||||
}
|
||||
// Set the file as found during node modules search if it was found that way in old progra,
|
||||
if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath)!)) {
|
||||
sourceFilesFoundSearchingNodeModules.set(filePath, true);
|
||||
@@ -1682,7 +1719,7 @@ namespace ts {
|
||||
|
||||
function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] | undefined {
|
||||
return runWithCancellationToken(() => {
|
||||
if (skipTypeChecking(sourceFile, options)) {
|
||||
if (skipTypeChecking(sourceFile, options, program)) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
@@ -2234,6 +2271,16 @@ namespace ts {
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, refFile: RefFile | undefined, packageId: PackageId | undefined): SourceFile | undefined {
|
||||
if (useSourceOfProjectReferenceRedirect) {
|
||||
const source = getSourceOfProjectReferenceRedirect(fileName);
|
||||
if (source) {
|
||||
const file = isString(source) ?
|
||||
findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
|
||||
undefined;
|
||||
if (file) addFileToFilesByName(file, path, /*redirectedPath*/ undefined);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
const originalFileName = fileName;
|
||||
if (filesByName.has(path)) {
|
||||
const file = filesByName.get(path);
|
||||
@@ -2282,7 +2329,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let redirectedPath: Path | undefined;
|
||||
if (refFile) {
|
||||
if (refFile && !useSourceOfProjectReferenceRedirect) {
|
||||
const redirectProject = getProjectReferenceRedirectProject(fileName);
|
||||
if (redirectProject) {
|
||||
if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
|
||||
@@ -2451,6 +2498,36 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getSourceOfProjectReferenceRedirect(file: string) {
|
||||
if (!isDeclarationFileName(file)) return undefined;
|
||||
if (mapFromToProjectReferenceRedirectSource === undefined) {
|
||||
mapFromToProjectReferenceRedirectSource = createMap();
|
||||
forEachResolvedProjectReference(resolvedRef => {
|
||||
if (resolvedRef) {
|
||||
const out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out;
|
||||
if (out) {
|
||||
// Dont know which source file it means so return true?
|
||||
const outputDts = changeExtension(out, Extension.Dts);
|
||||
mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), true);
|
||||
}
|
||||
else {
|
||||
forEach(resolvedRef.commandLine.fileNames, fileName => {
|
||||
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
|
||||
const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
|
||||
mapFromToProjectReferenceRedirectSource!.set(toPath(outputDts), fileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return mapFromToProjectReferenceRedirectSource.get(toPath(file));
|
||||
}
|
||||
|
||||
function isSourceOfProjectReferenceRedirect(fileName: string) {
|
||||
return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
|
||||
}
|
||||
|
||||
function forEachProjectReference<T>(
|
||||
projectReferences: readonly ProjectReference[] | undefined,
|
||||
resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined,
|
||||
@@ -2858,8 +2935,7 @@ namespace ts {
|
||||
const rootPaths = arrayToSet(rootNames, toPath);
|
||||
for (const file of files) {
|
||||
// Ignore file that is not emitted
|
||||
if (!sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue;
|
||||
if (!rootPaths.has(file.path)) {
|
||||
if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) {
|
||||
addProgramDiagnosticAtRefPath(
|
||||
file,
|
||||
rootPaths,
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace ts {
|
||||
abstract: SyntaxKind.AbstractKeyword,
|
||||
any: SyntaxKind.AnyKeyword,
|
||||
as: SyntaxKind.AsKeyword,
|
||||
asserts: SyntaxKind.AssertsKeyword,
|
||||
bigint: SyntaxKind.BigIntKeyword,
|
||||
boolean: SyntaxKind.BooleanKeyword,
|
||||
break: SyntaxKind.BreakKeyword,
|
||||
|
||||
+28
-19
@@ -522,6 +522,33 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function recursiveCreateDirectory(directoryPath: string, sys: System) {
|
||||
const basePath = getDirectoryPath(directoryPath);
|
||||
const shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath);
|
||||
if (shouldCreateParent) {
|
||||
recursiveCreateDirectory(basePath, sys);
|
||||
}
|
||||
if (shouldCreateParent || !sys.directoryExists(directoryPath)) {
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* patch writefile to create folder before writing the file
|
||||
*/
|
||||
/*@internal*/
|
||||
export function patchWriteFileEnsuringDirectory(sys: System) {
|
||||
// patch writefile to create folder before writing the file
|
||||
const originalWriteFile = sys.writeFile;
|
||||
sys.writeFile = (path, data, writeBom) => {
|
||||
const directoryPath = getDirectoryPath(normalizeSlashes(path));
|
||||
if (directoryPath && !sys.directoryExists(directoryPath)) {
|
||||
recursiveCreateDirectory(directoryPath, sys);
|
||||
}
|
||||
originalWriteFile.call(sys, path, data, writeBom);
|
||||
};
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
||||
|
||||
@@ -1367,17 +1394,6 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function recursiveCreateDirectory(directoryPath: string, sys: System) {
|
||||
const basePath = getDirectoryPath(directoryPath);
|
||||
const shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath);
|
||||
if (shouldCreateParent) {
|
||||
recursiveCreateDirectory(basePath, sys);
|
||||
}
|
||||
if (shouldCreateParent || !sys.directoryExists(directoryPath)) {
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
let sys: System | undefined;
|
||||
if (typeof ChakraHost !== "undefined") {
|
||||
sys = getChakraSystem();
|
||||
@@ -1389,14 +1405,7 @@ namespace ts {
|
||||
}
|
||||
if (sys) {
|
||||
// patch writefile to create folder before writing the file
|
||||
const originalWriteFile = sys.writeFile;
|
||||
sys.writeFile = (path, data, writeBom) => {
|
||||
const directoryPath = getDirectoryPath(normalizeSlashes(path));
|
||||
if (directoryPath && !sys!.directoryExists(directoryPath)) {
|
||||
recursiveCreateDirectory(directoryPath, sys!);
|
||||
}
|
||||
originalWriteFile.call(sys, path, data, writeBom);
|
||||
};
|
||||
patchWriteFileEnsuringDirectory(sys);
|
||||
}
|
||||
return sys!;
|
||||
})();
|
||||
|
||||
@@ -2871,7 +2871,7 @@ namespace ts {
|
||||
function tryEnterOrLeaveBlock(operationIndex: number): void {
|
||||
if (blocks) {
|
||||
for (; blockIndex < blockActions!.length && blockOffsets![blockIndex] <= operationIndex; blockIndex++) {
|
||||
const block = blocks[blockIndex];
|
||||
const block: CodeBlock = blocks[blockIndex];
|
||||
const blockAction = blockActions![blockIndex];
|
||||
switch (block.kind) {
|
||||
case CodeBlockKind.Exception:
|
||||
|
||||
+90
-25
@@ -32,6 +32,7 @@ namespace ts {
|
||||
| SyntaxKind.AbstractKeyword
|
||||
| SyntaxKind.AnyKeyword
|
||||
| SyntaxKind.AsKeyword
|
||||
| SyntaxKind.AssertsKeyword
|
||||
| SyntaxKind.BigIntKeyword
|
||||
| SyntaxKind.BooleanKeyword
|
||||
| SyntaxKind.BreakKeyword
|
||||
@@ -250,6 +251,7 @@ namespace ts {
|
||||
// Contextual keywords
|
||||
AbstractKeyword,
|
||||
AsKeyword,
|
||||
AssertsKeyword,
|
||||
AnyKeyword,
|
||||
AsyncKeyword,
|
||||
AwaitKeyword,
|
||||
@@ -361,8 +363,8 @@ namespace ts {
|
||||
SemicolonClassElement,
|
||||
// Element
|
||||
Block,
|
||||
VariableStatement,
|
||||
EmptyStatement,
|
||||
VariableStatement,
|
||||
ExpressionStatement,
|
||||
IfStatement,
|
||||
DoStatement,
|
||||
@@ -512,6 +514,8 @@ namespace ts {
|
||||
LastTemplateToken = TemplateTail,
|
||||
FirstBinaryOperator = LessThanToken,
|
||||
LastBinaryOperator = CaretEqualsToken,
|
||||
FirstStatement = VariableStatement,
|
||||
LastStatement = DebuggerStatement,
|
||||
FirstNode = QualifiedName,
|
||||
FirstJSDocNode = JSDocTypeExpression,
|
||||
LastJSDocNode = JSDocPropertyTag,
|
||||
@@ -614,9 +618,13 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export const enum RelationComparisonResult {
|
||||
Succeeded = 1, // Should be truthy
|
||||
Failed = 2,
|
||||
FailedAndReported = 3
|
||||
Succeeded = 1 << 0, // Should be truthy
|
||||
Failed = 1 << 1,
|
||||
Reported = 1 << 2,
|
||||
|
||||
ReportsUnmeasurable = 1 << 3,
|
||||
ReportsUnreliable = 1 << 4,
|
||||
ReportsMask = ReportsUnmeasurable | ReportsUnreliable
|
||||
}
|
||||
|
||||
export interface Node extends TextRange {
|
||||
@@ -736,6 +744,7 @@ namespace ts {
|
||||
export type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
export type PlusToken = Token<SyntaxKind.PlusToken>;
|
||||
export type MinusToken = Token<SyntaxKind.MinusToken>;
|
||||
export type AssertsToken = Token<SyntaxKind.AssertsKeyword>;
|
||||
|
||||
export type Modifier
|
||||
= Token<SyntaxKind.AbstractKeyword>
|
||||
@@ -1037,6 +1046,7 @@ namespace ts {
|
||||
questionToken?: QuestionToken;
|
||||
exclamationToken?: ExclamationToken;
|
||||
body?: Block | Expression;
|
||||
/* @internal */ endFlowNode?: FlowNode;
|
||||
}
|
||||
|
||||
export type FunctionLikeDeclaration =
|
||||
@@ -1180,8 +1190,9 @@ namespace ts {
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
assertsModifier?: AssertsToken;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
type?: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
@@ -2570,16 +2581,33 @@ namespace ts {
|
||||
FalseCondition = 1 << 6, // Condition known to be false
|
||||
SwitchClause = 1 << 7, // Switch statement clause
|
||||
ArrayMutation = 1 << 8, // Potential array mutation
|
||||
Referenced = 1 << 9, // Referenced as antecedent once
|
||||
Shared = 1 << 10, // Referenced as antecedent more than once
|
||||
PreFinally = 1 << 11, // Injected edge that links pre-finally label and pre-try flow
|
||||
AfterFinally = 1 << 12, // Injected edge that links post-finally flow with the rest of the graph
|
||||
Call = 1 << 9, // Potential assertion call
|
||||
Referenced = 1 << 10, // Referenced as antecedent once
|
||||
Shared = 1 << 11, // Referenced as antecedent more than once
|
||||
PreFinally = 1 << 12, // Injected edge that links pre-finally label and pre-try flow
|
||||
AfterFinally = 1 << 13, // Injected edge that links post-finally flow with the rest of the graph
|
||||
/** @internal */
|
||||
Cached = 1 << 13, // Indicates that at least one cross-call cache entry exists for this node, even if not a loop participant
|
||||
Cached = 1 << 14, // Indicates that at least one cross-call cache entry exists for this node, even if not a loop participant
|
||||
Label = BranchLabel | LoopLabel,
|
||||
Condition = TrueCondition | FalseCondition
|
||||
}
|
||||
|
||||
export type FlowNode =
|
||||
| AfterFinallyFlow
|
||||
| PreFinallyFlow
|
||||
| FlowStart
|
||||
| FlowLabel
|
||||
| FlowAssignment
|
||||
| FlowCall
|
||||
| FlowCondition
|
||||
| FlowSwitchClause
|
||||
| FlowArrayMutation;
|
||||
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number; // Node id used by flow type cache in checker
|
||||
}
|
||||
|
||||
export interface FlowLock {
|
||||
locked?: boolean;
|
||||
}
|
||||
@@ -2593,18 +2621,11 @@ namespace ts {
|
||||
lock: FlowLock;
|
||||
}
|
||||
|
||||
export type FlowNode =
|
||||
| AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number; // Node id used by flow type cache in checker
|
||||
}
|
||||
|
||||
// FlowStart represents the start of a control flow. For a function expression or arrow
|
||||
// function, the container property references the function (which in turn has a flowNode
|
||||
// function, the node property references the function (which in turn has a flowNode
|
||||
// property for the containing control flow).
|
||||
export interface FlowStart extends FlowNodeBase {
|
||||
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
node?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
}
|
||||
|
||||
// FlowLabel represents a junction with multiple possible preceding control flows.
|
||||
@@ -2619,10 +2640,15 @@ namespace ts {
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
export interface FlowCall extends FlowNodeBase {
|
||||
node: CallExpression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
// FlowCondition represents a condition that is known to be true or false at the
|
||||
// node's location in the control flow.
|
||||
export interface FlowCondition extends FlowNodeBase {
|
||||
expression: Expression;
|
||||
node: Expression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
@@ -3039,6 +3065,7 @@ namespace ts {
|
||||
/*@internal*/ getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined;
|
||||
/*@internal*/ forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference | undefined, resolvedProjectReferencePath: Path) => T | undefined): T | undefined;
|
||||
/*@internal*/ getResolvedProjectReferenceByPath(projectReferencePath: Path): ResolvedProjectReference | undefined;
|
||||
/*@internal*/ isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
/*@internal*/ getProgramBuildInfo?(): ProgramBuildInfo | undefined;
|
||||
/*@internal*/ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
||||
}
|
||||
@@ -3139,6 +3166,7 @@ namespace ts {
|
||||
getSourceFile(fileName: string): SourceFile | undefined;
|
||||
getResolvedTypeReferenceDirectives(): ReadonlyMap<ResolvedTypeReferenceDirective | undefined>;
|
||||
getProjectReferenceRedirect(fileName: string): string | undefined;
|
||||
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
|
||||
readonly redirectTargetsMap: RedirectTargetsMap;
|
||||
}
|
||||
@@ -3289,6 +3317,7 @@ namespace ts {
|
||||
/* @internal */ getElementTypeOfArrayType(arrayType: Type): Type | undefined;
|
||||
/* @internal */ createPromiseType(type: Type): Type;
|
||||
|
||||
/* @internal */ isTypeAssignableTo(source: Type, target: Type): boolean;
|
||||
/* @internal */ createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): Type;
|
||||
/* @internal */ createSignature(
|
||||
declaration: SignatureDeclaration,
|
||||
@@ -3527,25 +3556,45 @@ namespace ts {
|
||||
|
||||
export const enum TypePredicateKind {
|
||||
This,
|
||||
Identifier
|
||||
Identifier,
|
||||
AssertsThis,
|
||||
AssertsIdentifier
|
||||
}
|
||||
|
||||
export interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
type: Type | undefined;
|
||||
}
|
||||
|
||||
export interface ThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.This;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
export interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.Identifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
export interface AssertsThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsThis;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type | undefined;
|
||||
}
|
||||
|
||||
export interface AssertsIdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsIdentifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type | undefined;
|
||||
}
|
||||
|
||||
export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate;
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
@@ -3963,7 +4012,7 @@ namespace ts {
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||
maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate
|
||||
effectsSignature?: Signature; // Signature with possible control flow effects
|
||||
enumMemberValue?: string | number; // Constant value of enum member
|
||||
isVisible?: boolean; // Is this node visible
|
||||
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
||||
@@ -3978,6 +4027,7 @@ namespace ts {
|
||||
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
|
||||
deferredNodes?: Map<Node>; // Set of nodes whose checking has been deferred
|
||||
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
|
||||
isExhaustive?: boolean; // Is node an exhaustive switch statement
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -4202,7 +4252,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Object type or intersection of object types
|
||||
export type BaseType = ObjectType | IntersectionType;
|
||||
export type BaseType = ObjectType | IntersectionType | TypeVariable; // Also `any` and `object`
|
||||
|
||||
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[]; // Declared members
|
||||
@@ -4631,6 +4681,8 @@ namespace ts {
|
||||
code: number;
|
||||
message: string;
|
||||
reportsUnnecessary?: {};
|
||||
/* @internal */
|
||||
elidedInCompatabilityPyramid?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4725,6 +4777,7 @@ namespace ts {
|
||||
/* @internal */ diagnostics?: boolean;
|
||||
/* @internal */ extendedDiagnostics?: boolean;
|
||||
disableSizeLimit?: boolean;
|
||||
disableSourceOfProjectReferenceRedirect?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
@@ -5253,11 +5306,23 @@ namespace ts {
|
||||
/* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean;
|
||||
createHash?(data: string): string;
|
||||
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
|
||||
/* @internal */ setResolvedProjectReferenceCallbacks?(callbacks: ResolvedProjectReferenceCallbacks): void;
|
||||
/* @internal */ useSourceOfProjectReferenceRedirect?(): boolean;
|
||||
|
||||
// TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesn't use compilerHost as base
|
||||
/*@internal*/createDirectory?(directory: string): void;
|
||||
}
|
||||
|
||||
/** true if --out otherwise source file name */
|
||||
/*@internal*/
|
||||
export type SourceOfProjectReferenceRedirect = string | true;
|
||||
|
||||
/*@internal*/
|
||||
export interface ResolvedProjectReferenceCallbacks {
|
||||
getSourceOfProjectReferenceRedirect(fileName: string): SourceOfProjectReferenceRedirect | undefined;
|
||||
forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference | undefined, resolvedProjectReferencePath: Path) => T | undefined): T | undefined;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum TransformFlags {
|
||||
None = 0,
|
||||
|
||||
@@ -8713,11 +8713,16 @@ namespace ts {
|
||||
return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
|
||||
}
|
||||
|
||||
export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions) {
|
||||
export interface HostWithIsSourceOfProjectReferenceRedirect {
|
||||
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
|
||||
}
|
||||
export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions, host: HostWithIsSourceOfProjectReferenceRedirect) {
|
||||
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
|
||||
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
|
||||
// '/// <reference no-default-lib="true"/>' directive.
|
||||
return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib;
|
||||
return (options.skipLibCheck && sourceFile.isDeclarationFile ||
|
||||
options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
|
||||
host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
|
||||
}
|
||||
|
||||
export function isJsonEqual(a: unknown, b: unknown): boolean {
|
||||
|
||||
@@ -333,7 +333,8 @@ namespace ts {
|
||||
|
||||
// Types
|
||||
case SyntaxKind.TypePredicate:
|
||||
return updateTypePredicateNode(<TypePredicateNode>node,
|
||||
return updateTypePredicateNodeWithModifier(<TypePredicateNode>node,
|
||||
visitNode((<TypePredicateNode>node).assertsModifier, visitor),
|
||||
visitNode((<TypePredicateNode>node).parameterName, visitor),
|
||||
visitNode((<TypePredicateNode>node).type, visitor, isTypeNode));
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
|
||||
export function createServerHost(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
return new TestServerHost(/*withSafelist*/ true, fileOrFolderList, params);
|
||||
const host = new TestServerHost(/*withSafelist*/ true, fileOrFolderList, params);
|
||||
// Just like sys, patch the host to use writeFile
|
||||
patchWriteFileEnsuringDirectory(host);
|
||||
return host;
|
||||
}
|
||||
|
||||
export interface File {
|
||||
@@ -174,8 +177,8 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
}
|
||||
|
||||
export function checkWatchedFiles(host: TestServerHost, expectedFiles: string[]) {
|
||||
checkMapKeys("watchedFiles", host.watchedFiles, expectedFiles);
|
||||
export function checkWatchedFiles(host: TestServerHost, expectedFiles: string[], additionalInfo?: string) {
|
||||
checkMapKeys(`watchedFiles:: ${additionalInfo || ""}::`, host.watchedFiles, expectedFiles);
|
||||
}
|
||||
|
||||
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<number>): void;
|
||||
@@ -1016,6 +1019,19 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
}
|
||||
|
||||
export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: Map<true>; };
|
||||
|
||||
export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) {
|
||||
const host = inputHost as TestServerHostTrackingWrittenFiles;
|
||||
const originalWriteFile = host.writeFile;
|
||||
host.writtenFiles = createMap<true>();
|
||||
host.writeFile = (fileName, content) => {
|
||||
originalWriteFile.call(host, fileName, content);
|
||||
const path = host.toFullPath(fileName);
|
||||
host.writtenFiles.set(path, true);
|
||||
};
|
||||
return host;
|
||||
}
|
||||
export const tsbuildProjectsLocation = "/user/username/projects";
|
||||
export function getTsBuildProjectFilePath(project: string, file: string) {
|
||||
return `${tsbuildProjectsLocation}/${project}/${file}`;
|
||||
|
||||
Vendored
+11
-11
@@ -18,7 +18,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -26,7 +26,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: readonly [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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -34,7 +34,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: readonly [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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -42,7 +42,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5, T6, T7>(values: readonly [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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -50,7 +50,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5, T6>(values: readonly [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]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -58,7 +58,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<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]>;
|
||||
all<T1, T2, T3, T4, T5>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -66,7 +66,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
all<T1, T2, T3, T4>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -74,7 +74,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
all<T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -82,7 +82,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
all<T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
@@ -90,7 +90,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
all<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
@@ -98,7 +98,7 @@ interface PromiseConstructor {
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: T[]): Promise<T extends PromiseLike<infer U> ? U : T>;
|
||||
race<T>(values: readonly T[]): Promise<T extends PromiseLike<infer U> ? U : T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
|
||||
@@ -1777,6 +1777,12 @@ namespace ts.server {
|
||||
configFileErrors.push(...parsedCommandLine.errors);
|
||||
}
|
||||
|
||||
this.logger.info(`Config: ${configFilename} : ${JSON.stringify({
|
||||
rootNames: parsedCommandLine.fileNames,
|
||||
options: parsedCommandLine.options,
|
||||
projectReferences: parsedCommandLine.projectReferences
|
||||
}, /*replacer*/ undefined, " ")}`);
|
||||
|
||||
Debug.assert(!!parsedCommandLine.fileNames);
|
||||
const compilerOptions = parsedCommandLine.options;
|
||||
|
||||
@@ -1818,7 +1824,7 @@ namespace ts.server {
|
||||
let scriptInfo: ScriptInfo | NormalizedPath;
|
||||
let path: Path;
|
||||
// Use the project's fileExists so that it can use caching instead of reaching to disk for the query
|
||||
if (!isDynamic && !project.fileExists(newRootFile)) {
|
||||
if (!isDynamic && !project.fileExistsWithCache(newRootFile)) {
|
||||
path = normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName);
|
||||
const existingValue = projectRootFilesMap.get(path)!;
|
||||
if (isScriptInfo(existingValue)) {
|
||||
@@ -1851,7 +1857,7 @@ namespace ts.server {
|
||||
projectRootFilesMap.forEach((value, path) => {
|
||||
if (!newRootScriptInfoMap.has(path)) {
|
||||
if (isScriptInfo(value)) {
|
||||
project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true);
|
||||
project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true);
|
||||
}
|
||||
else {
|
||||
projectRootFilesMap.delete(path);
|
||||
@@ -2584,7 +2590,9 @@ namespace ts.server {
|
||||
|
||||
/*@internal*/
|
||||
getOriginalLocationEnsuringConfiguredProject(project: Project, location: DocumentPosition): DocumentPosition | undefined {
|
||||
const originalLocation = project.getSourceMapper().tryGetSourcePosition(location);
|
||||
const originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ?
|
||||
location :
|
||||
project.getSourceMapper().tryGetSourcePosition(location);
|
||||
if (!originalLocation) return undefined;
|
||||
|
||||
const { fileName } = originalLocation;
|
||||
@@ -2595,7 +2603,8 @@ namespace ts.server {
|
||||
if (!configFileName) return undefined;
|
||||
|
||||
const configuredProject = this.findConfiguredProjectByProjectName(configFileName) ||
|
||||
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName} for location: ${location.fileName}`);
|
||||
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location: " + location.fileName : ""}`);
|
||||
if (configuredProject === project) return originalLocation;
|
||||
updateProjectIfDirty(configuredProject);
|
||||
// Keep this configured project as referenced from project
|
||||
addOriginalConfiguredProject(configuredProject);
|
||||
|
||||
+90
-3
@@ -196,6 +196,11 @@ namespace ts.server {
|
||||
/*@internal*/
|
||||
originalConfiguredProjects: Map<true> | undefined;
|
||||
|
||||
/*@internal*/
|
||||
getResolvedProjectReferenceToRedirect(_fileName: string): ResolvedProjectReference | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private readonly cancellationToken: ThrottledCancellationToken;
|
||||
|
||||
public isNonTsProject() {
|
||||
@@ -391,6 +396,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
fileExists(file: string): boolean {
|
||||
return this.fileExistsWithCache(file);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
fileExistsWithCache(file: string): boolean {
|
||||
// As an optimization, don't hit the disks for files we already know don't exist
|
||||
// (because we're watching for their creation).
|
||||
const path = this.toPath(file);
|
||||
@@ -527,8 +537,11 @@ namespace ts.server {
|
||||
return this.projectService.getSourceFileLike(fileName, this);
|
||||
}
|
||||
|
||||
private shouldEmitFile(scriptInfo: ScriptInfo) {
|
||||
return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent();
|
||||
/*@internal*/
|
||||
shouldEmitFile(scriptInfo: ScriptInfo | undefined) {
|
||||
return scriptInfo &&
|
||||
!scriptInfo.isDynamicOrHasMixedContent() &&
|
||||
!this.program!.isSourceOfProjectReferenceRedirect(scriptInfo.path);
|
||||
}
|
||||
|
||||
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[] {
|
||||
@@ -538,7 +551,7 @@ namespace ts.server {
|
||||
updateProjectIfDirty(this);
|
||||
this.builderState = BuilderState.create(this.program!, this.projectService.toCanonicalFileName, this.builderState);
|
||||
return mapDefined(BuilderState.getFilesAffectedBy(this.builderState, this.program!, scriptInfo.path, this.cancellationToken, data => this.projectService.host.createHash!(data)), // TODO: GH#18217
|
||||
sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)!) ? sourceFile.fileName : undefined);
|
||||
sourceFile => this.shouldEmitFile(this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1223,6 +1236,11 @@ namespace ts.server {
|
||||
this.rootFilesMap.delete(info.path);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
isSourceOfProjectReferenceRedirect(fileName: string) {
|
||||
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
|
||||
}
|
||||
|
||||
protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined) {
|
||||
const host = this.projectService.host;
|
||||
|
||||
@@ -1475,6 +1493,8 @@ namespace ts.server {
|
||||
configFileWatcher: FileWatcher | undefined;
|
||||
private directoriesWatchedForWildcards: Map<WildcardDirectoryWatcher> | undefined;
|
||||
readonly canonicalConfigFilePath: NormalizedPath;
|
||||
private projectReferenceCallbacks: ResolvedProjectReferenceCallbacks | undefined;
|
||||
private mapOfDeclarationDirectories: Map<true> | undefined;
|
||||
|
||||
/* @internal */
|
||||
pendingReload: ConfigFileProgramReloadLevel | undefined;
|
||||
@@ -1520,6 +1540,63 @@ namespace ts.server {
|
||||
this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName));
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
setResolvedProjectReferenceCallbacks(projectReferenceCallbacks: ResolvedProjectReferenceCallbacks) {
|
||||
this.projectReferenceCallbacks = projectReferenceCallbacks;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
useSourceOfProjectReferenceRedirect = () => !!this.languageServiceEnabled &&
|
||||
!this.getCompilerOptions().disableSourceOfProjectReferenceRedirect;
|
||||
|
||||
/**
|
||||
* This implementation of fileExists checks if the file being requested is
|
||||
* .d.ts file for the referenced Project.
|
||||
* If it is it returns true irrespective of whether that file exists on host
|
||||
*/
|
||||
fileExists(file: string): boolean {
|
||||
// Project references go to source file instead of .d.ts file
|
||||
if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) {
|
||||
const source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file);
|
||||
if (source) return isString(source) ? super.fileExists(source) : true;
|
||||
}
|
||||
return super.fileExists(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation of directoryExists checks if the directory being requested is
|
||||
* directory of .d.ts file for the referenced Project.
|
||||
* If it is it returns true irrespective of whether that directory exists on host
|
||||
*/
|
||||
directoryExists(path: string): boolean {
|
||||
if (super.directoryExists(path)) return true;
|
||||
if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return false;
|
||||
|
||||
if (!this.mapOfDeclarationDirectories) {
|
||||
this.mapOfDeclarationDirectories = createMap();
|
||||
this.projectReferenceCallbacks.forEachResolvedProjectReference(ref => {
|
||||
if (!ref) return;
|
||||
const out = ref.commandLine.options.outFile || ref.commandLine.options.outDir;
|
||||
if (out) {
|
||||
this.mapOfDeclarationDirectories!.set(getDirectoryPath(this.toPath(out)), true);
|
||||
}
|
||||
else {
|
||||
// Set declaration's in different locations only, if they are next to source the directory present doesnt change
|
||||
const declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
|
||||
if (declarationDir) {
|
||||
this.mapOfDeclarationDirectories!.set(this.toPath(declarationDir), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
const dirPath = this.toPath(path);
|
||||
const dirPathWithTrailingDirectorySeparator = `${dirPath}${directorySeparator}`;
|
||||
return !!forEachKey(
|
||||
this.mapOfDeclarationDirectories,
|
||||
declDirPath => dirPath === declDirPath || startsWith(declDirPath, dirPathWithTrailingDirectorySeparator)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
|
||||
* @returns: true if set of files in the project stays the same and false - otherwise.
|
||||
@@ -1528,6 +1605,8 @@ namespace ts.server {
|
||||
this.isInitialLoadPending = returnFalse;
|
||||
const reloadLevel = this.pendingReload;
|
||||
this.pendingReload = ConfigFileProgramReloadLevel.None;
|
||||
this.projectReferenceCallbacks = undefined;
|
||||
this.mapOfDeclarationDirectories = undefined;
|
||||
let result: boolean;
|
||||
switch (reloadLevel) {
|
||||
case ConfigFileProgramReloadLevel.Partial:
|
||||
@@ -1570,6 +1649,12 @@ namespace ts.server {
|
||||
return program && program.forEachResolvedProjectReference(cb);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined {
|
||||
const program = this.getCurrentProgram();
|
||||
return program && program.getResolvedProjectReferenceToRedirect(fileName);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined) {
|
||||
const host = this.projectService.host;
|
||||
@@ -1652,6 +1737,8 @@ namespace ts.server {
|
||||
this.stopWatchingWildCards();
|
||||
this.projectErrors = undefined;
|
||||
this.configFileSpecs = undefined;
|
||||
this.projectReferenceCallbacks = undefined;
|
||||
this.mapOfDeclarationDirectories = undefined;
|
||||
super.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -495,15 +495,17 @@ namespace ts.server {
|
||||
// the default project; if no configured projects, the first external project should
|
||||
// be the default project; otherwise the first inferred project should be the default.
|
||||
let firstExternalProject;
|
||||
let firstConfiguredProject;
|
||||
for (const project of this.containingProjects) {
|
||||
if (project.projectKind === ProjectKind.Configured) {
|
||||
return project;
|
||||
if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) return project;
|
||||
if (!firstConfiguredProject) firstConfiguredProject = project;
|
||||
}
|
||||
else if (project.projectKind === ProjectKind.External && !firstExternalProject) {
|
||||
firstExternalProject = project;
|
||||
}
|
||||
}
|
||||
return firstExternalProject || this.containingProjects[0];
|
||||
return firstConfiguredProject || firstExternalProject || this.containingProjects[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -448,7 +448,9 @@ namespace ts.server {
|
||||
|
||||
function getDefinitionInProject(definition: DocumentPosition | undefined, definingProject: Project, project: Project): DocumentPosition | undefined {
|
||||
if (!definition || project.containsFile(toNormalizedPath(definition.fileName))) return definition;
|
||||
const mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition);
|
||||
const mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ?
|
||||
definition :
|
||||
definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition);
|
||||
return mappedDefinition && project.containsFile(toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined;
|
||||
}
|
||||
|
||||
@@ -477,7 +479,7 @@ namespace ts.server {
|
||||
for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: originalLocation as TLocation }, toDo!, seenProjects);
|
||||
});
|
||||
}
|
||||
return originalLocation;
|
||||
return originalLocation === location ? undefined : originalLocation;
|
||||
});
|
||||
return toDo;
|
||||
}
|
||||
@@ -1037,7 +1039,9 @@ namespace ts.server {
|
||||
|
||||
private getEmitOutput(args: protocol.FileRequestArgs): EmitOutput {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
return project.getLanguageService().getEmitOutput(file);
|
||||
return project.shouldEmitFile(project.getScriptInfo(file)) ?
|
||||
project.getLanguageService().getEmitOutput(file) :
|
||||
{ emitSkipped: true, outputFiles: [] };
|
||||
}
|
||||
|
||||
private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] {
|
||||
@@ -1672,10 +1676,10 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private createCheckList(fileNames: string[], defaultProject?: Project): PendingErrorCheck[] {
|
||||
private createCheckList(fileNames: string[]): PendingErrorCheck[] {
|
||||
return mapDefined<string, PendingErrorCheck>(fileNames, uncheckedFileName => {
|
||||
const fileName = toNormalizedPath(uncheckedFileName);
|
||||
const project = defaultProject || this.projectService.tryGetDefaultProjectForFile(fileName);
|
||||
const project = this.projectService.tryGetDefaultProjectForFile(fileName);
|
||||
return project && { fileName, project };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -393,6 +393,19 @@ namespace ts.codefix {
|
||||
|
||||
function inferTypeFromReferences(program: Program, references: readonly Identifier[], cancellationToken: CancellationToken) {
|
||||
const checker = program.getTypeChecker();
|
||||
const builtinConstructors: { [s: string]: (t: Type) => Type } = {
|
||||
string: () => checker.getStringType(),
|
||||
number: () => checker.getNumberType(),
|
||||
Array: t => checker.createArrayType(t),
|
||||
Promise: t => checker.createPromiseType(t),
|
||||
};
|
||||
const builtins = [
|
||||
checker.getStringType(),
|
||||
checker.getNumberType(),
|
||||
checker.createArrayType(checker.getAnyType()),
|
||||
checker.createPromiseType(checker.getAnyType()),
|
||||
];
|
||||
|
||||
return {
|
||||
single,
|
||||
parameters,
|
||||
@@ -401,26 +414,74 @@ namespace ts.codefix {
|
||||
|
||||
interface CallUsage {
|
||||
argumentTypes: Type[];
|
||||
returnType: Usage;
|
||||
return_: Usage;
|
||||
}
|
||||
|
||||
interface Usage {
|
||||
isNumber?: boolean;
|
||||
isString?: boolean;
|
||||
isNumber: boolean | undefined;
|
||||
isString: boolean | undefined;
|
||||
/** Used ambiguously, eg x + ___ or object[___]; results in string | number if no other evidence exists */
|
||||
isNumberOrString?: boolean;
|
||||
isNumberOrString: boolean | undefined;
|
||||
|
||||
candidateTypes?: Type[];
|
||||
properties?: UnderscoreEscapedMap<Usage>;
|
||||
calls?: CallUsage[];
|
||||
constructs?: CallUsage[];
|
||||
numberIndex?: Usage;
|
||||
stringIndex?: Usage;
|
||||
candidateThisTypes?: Type[];
|
||||
candidateTypes: Type[] | undefined;
|
||||
properties: UnderscoreEscapedMap<Usage> | undefined;
|
||||
calls: CallUsage[] | undefined;
|
||||
constructs: CallUsage[] | undefined;
|
||||
numberIndex: Usage | undefined;
|
||||
stringIndex: Usage | undefined;
|
||||
candidateThisTypes: Type[] | undefined;
|
||||
inferredTypes: Type[] | undefined;
|
||||
}
|
||||
|
||||
function createEmptyUsage(): Usage {
|
||||
return {
|
||||
isNumber: undefined,
|
||||
isString: undefined,
|
||||
isNumberOrString: undefined,
|
||||
candidateTypes: undefined,
|
||||
properties: undefined,
|
||||
calls: undefined,
|
||||
constructs: undefined,
|
||||
numberIndex: undefined,
|
||||
stringIndex: undefined,
|
||||
candidateThisTypes: undefined,
|
||||
inferredTypes: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function combineUsages(usages: Usage[]): Usage {
|
||||
const combinedProperties = createUnderscoreEscapedMap<Usage[]>();
|
||||
for (const u of usages) {
|
||||
if (u.properties) {
|
||||
u.properties.forEach((p, name) => {
|
||||
if (!combinedProperties.has(name)) {
|
||||
combinedProperties.set(name, []);
|
||||
}
|
||||
combinedProperties.get(name)!.push(p);
|
||||
});
|
||||
}
|
||||
}
|
||||
const properties = createUnderscoreEscapedMap<Usage>();
|
||||
combinedProperties.forEach((ps, name) => {
|
||||
properties.set(name, combineUsages(ps));
|
||||
});
|
||||
return {
|
||||
isNumber: usages.some(u => u.isNumber),
|
||||
isString: usages.some(u => u.isString),
|
||||
isNumberOrString: usages.some(u => u.isNumberOrString),
|
||||
candidateTypes: flatMap(usages, u => u.candidateTypes) as Type[],
|
||||
properties,
|
||||
calls: flatMap(usages, u => u.calls) as CallUsage[],
|
||||
constructs: flatMap(usages, u => u.constructs) as CallUsage[],
|
||||
numberIndex: forEach(usages, u => u.numberIndex),
|
||||
stringIndex: forEach(usages, u => u.stringIndex),
|
||||
candidateThisTypes: flatMap(usages, u => u.candidateThisTypes) as Type[],
|
||||
inferredTypes: undefined, // clear type cache
|
||||
};
|
||||
}
|
||||
|
||||
function single(): Type {
|
||||
return unifyFromUsage(inferTypesFromReferencesSingle(references));
|
||||
return combineTypes(inferTypesFromReferencesSingle(references));
|
||||
}
|
||||
|
||||
function parameters(declaration: FunctionLike): ParameterInference[] | undefined {
|
||||
@@ -428,7 +489,7 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const usage: Usage = {};
|
||||
const usage = createEmptyUsage();
|
||||
for (const reference of references) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
calculateUsageOfNode(reference, usage);
|
||||
@@ -456,7 +517,7 @@ namespace ts.codefix {
|
||||
const inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken));
|
||||
types.push(...(isRest ? mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred));
|
||||
}
|
||||
const type = unifyFromUsage(types);
|
||||
const type = combineTypes(types);
|
||||
return {
|
||||
type: isRest ? checker.createArrayType(type) : type,
|
||||
isOptional: isOptional && !isRest,
|
||||
@@ -466,22 +527,22 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function thisParameter() {
|
||||
const usage: Usage = {};
|
||||
const usage = createEmptyUsage();
|
||||
for (const reference of references) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
calculateUsageOfNode(reference, usage);
|
||||
}
|
||||
|
||||
return unifyFromUsage(usage.candidateThisTypes || emptyArray);
|
||||
return combineTypes(usage.candidateThisTypes || emptyArray);
|
||||
}
|
||||
|
||||
function inferTypesFromReferencesSingle(references: readonly Identifier[]): Type[] {
|
||||
const usage: Usage = {};
|
||||
const usage: Usage = createEmptyUsage();
|
||||
for (const reference of references) {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
calculateUsageOfNode(reference, usage);
|
||||
}
|
||||
return inferFromUsage(usage);
|
||||
return inferTypes(usage);
|
||||
}
|
||||
|
||||
function calculateUsageOfNode(node: Expression, usage: Usage): void {
|
||||
@@ -490,6 +551,9 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
addCandidateType(usage, checker.getVoidType());
|
||||
break;
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
usage.isNumber = true;
|
||||
break;
|
||||
@@ -632,6 +696,9 @@ namespace ts.codefix {
|
||||
else if (otherOperandType.flags & TypeFlags.StringLike) {
|
||||
usage.isString = true;
|
||||
}
|
||||
else if (otherOperandType.flags & TypeFlags.Any) {
|
||||
// do nothing, maybe we'll learn something elsewhere
|
||||
}
|
||||
else {
|
||||
usage.isNumberOrString = true;
|
||||
}
|
||||
@@ -677,7 +744,7 @@ namespace ts.codefix {
|
||||
function inferTypeFromCallExpression(parent: CallExpression | NewExpression, usage: Usage): void {
|
||||
const call: CallUsage = {
|
||||
argumentTypes: [],
|
||||
returnType: {}
|
||||
return_: createEmptyUsage()
|
||||
};
|
||||
|
||||
if (parent.arguments) {
|
||||
@@ -686,7 +753,7 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
calculateUsageOfNode(parent, call.returnType);
|
||||
calculateUsageOfNode(parent, call.return_);
|
||||
if (parent.kind === SyntaxKind.CallExpression) {
|
||||
(usage.calls || (usage.calls = [])).push(call);
|
||||
}
|
||||
@@ -700,7 +767,7 @@ namespace ts.codefix {
|
||||
if (!usage.properties) {
|
||||
usage.properties = createUnderscoreEscapedMap<Usage>();
|
||||
}
|
||||
const propertyUsage = usage.properties.get(name) || { };
|
||||
const propertyUsage = usage.properties.get(name) || createEmptyUsage();
|
||||
calculateUsageOfNode(parent, propertyUsage);
|
||||
usage.properties.set(name, propertyUsage);
|
||||
}
|
||||
@@ -712,7 +779,7 @@ namespace ts.codefix {
|
||||
}
|
||||
else {
|
||||
const indexType = checker.getTypeAtLocation(parent.argumentExpression);
|
||||
const indexUsage = {};
|
||||
const indexUsage = createEmptyUsage();
|
||||
calculateUsageOfNode(parent, indexUsage);
|
||||
if (indexType.flags & TypeFlags.NumberLike) {
|
||||
usage.numberIndex = indexUsage;
|
||||
@@ -752,8 +819,12 @@ namespace ts.codefix {
|
||||
return inferences.filter(i => toRemove.every(f => !f(i)));
|
||||
}
|
||||
|
||||
function unifyFromUsage(inferences: readonly Type[], fallback = checker.getAnyType()): Type {
|
||||
if (!inferences.length) return fallback;
|
||||
function combineFromUsage(usage: Usage) {
|
||||
return combineTypes(inferTypes(usage));
|
||||
}
|
||||
|
||||
function combineTypes(inferences: readonly Type[]): Type {
|
||||
if (!inferences.length) return checker.getAnyType();
|
||||
|
||||
// 1. string or number individually override string | number
|
||||
// 2. non-any, non-void overrides any or void
|
||||
@@ -776,12 +847,12 @@ namespace ts.codefix {
|
||||
const anons = good.filter(i => checker.getObjectFlags(i) & ObjectFlags.Anonymous) as AnonymousType[];
|
||||
if (anons.length) {
|
||||
good = good.filter(i => !(checker.getObjectFlags(i) & ObjectFlags.Anonymous));
|
||||
good.push(unifyAnonymousTypes(anons));
|
||||
good.push(combineAnonymousTypes(anons));
|
||||
}
|
||||
return checker.getWidenedType(checker.getUnionType(good));
|
||||
return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), UnionReduction.Subtype));
|
||||
}
|
||||
|
||||
function unifyAnonymousTypes(anons: AnonymousType[]) {
|
||||
function combineAnonymousTypes(anons: AnonymousType[]) {
|
||||
if (anons.length === 1) {
|
||||
return anons[0];
|
||||
}
|
||||
@@ -822,7 +893,7 @@ namespace ts.codefix {
|
||||
numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined);
|
||||
}
|
||||
|
||||
function inferFromUsage(usage: Usage) {
|
||||
function inferTypes(usage: Usage): Type[] {
|
||||
const types = [];
|
||||
|
||||
if (usage.isNumber) {
|
||||
@@ -834,92 +905,155 @@ namespace ts.codefix {
|
||||
if (usage.isNumberOrString) {
|
||||
types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()]));
|
||||
}
|
||||
if (usage.numberIndex) {
|
||||
types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
|
||||
}
|
||||
if (usage.properties && usage.properties.size
|
||||
|| usage.calls && usage.calls.length
|
||||
|| usage.constructs && usage.constructs.length
|
||||
|| usage.stringIndex) {
|
||||
types.push(inferStructuralType(usage));
|
||||
}
|
||||
|
||||
types.push(...(usage.candidateTypes || []).map(t => checker.getBaseTypeOfLiteralType(t)));
|
||||
types.push(...inferNamedTypesFromProperties(usage));
|
||||
|
||||
if (usage.properties && hasCalls(usage.properties.get("then" as __String))) {
|
||||
const paramType = getParameterTypeFromCalls(0, usage.properties.get("then" as __String)!.calls!, /*isRestParameter*/ false)!; // TODO: GH#18217
|
||||
const types = paramType.getCallSignatures().map(sig => sig.getReturnType());
|
||||
types.push(checker.createPromiseType(types.length ? checker.getUnionType(types, UnionReduction.Subtype) : checker.getAnyType()));
|
||||
}
|
||||
else if (usage.properties && hasCalls(usage.properties.get("push" as __String))) {
|
||||
types.push(checker.createArrayType(getParameterTypeFromCalls(0, usage.properties.get("push" as __String)!.calls!, /*isRestParameter*/ false)!));
|
||||
}
|
||||
|
||||
if (usage.numberIndex) {
|
||||
types.push(checker.createArrayType(recur(usage.numberIndex)));
|
||||
}
|
||||
else if (usage.properties || usage.calls || usage.constructs || usage.stringIndex) {
|
||||
const members = createUnderscoreEscapedMap<Symbol>();
|
||||
const callSignatures: Signature[] = [];
|
||||
const constructSignatures: Signature[] = [];
|
||||
let stringIndexInfo: IndexInfo | undefined;
|
||||
|
||||
if (usage.properties) {
|
||||
usage.properties.forEach((u, name) => {
|
||||
const symbol = checker.createSymbol(SymbolFlags.Property, name);
|
||||
symbol.type = recur(u);
|
||||
members.set(name, symbol);
|
||||
});
|
||||
}
|
||||
|
||||
if (usage.calls) {
|
||||
for (const call of usage.calls) {
|
||||
callSignatures.push(getSignatureFromCall(call));
|
||||
}
|
||||
}
|
||||
|
||||
if (usage.constructs) {
|
||||
for (const construct of usage.constructs) {
|
||||
constructSignatures.push(getSignatureFromCall(construct));
|
||||
}
|
||||
}
|
||||
|
||||
if (usage.stringIndex) {
|
||||
stringIndexInfo = checker.createIndexInfo(recur(usage.stringIndex), /*isReadonly*/ false);
|
||||
}
|
||||
|
||||
types.push(checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217
|
||||
}
|
||||
return types;
|
||||
|
||||
function recur(innerUsage: Usage): Type {
|
||||
return unifyFromUsage(inferFromUsage(innerUsage));
|
||||
}
|
||||
}
|
||||
|
||||
function getParameterTypeFromCalls(parameterIndex: number, calls: CallUsage[], isRestParameter: boolean) {
|
||||
let types: Type[] = [];
|
||||
if (calls) {
|
||||
for (const call of calls) {
|
||||
if (call.argumentTypes.length > parameterIndex) {
|
||||
if (isRestParameter) {
|
||||
types = concatenate(types, map(call.argumentTypes.slice(parameterIndex), a => checker.getBaseTypeOfLiteralType(a)));
|
||||
}
|
||||
else {
|
||||
types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex]));
|
||||
function inferStructuralType(usage: Usage) {
|
||||
const members = createUnderscoreEscapedMap<Symbol>();
|
||||
if (usage.properties) {
|
||||
usage.properties.forEach((u, name) => {
|
||||
const symbol = checker.createSymbol(SymbolFlags.Property, name);
|
||||
symbol.type = combineFromUsage(u);
|
||||
members.set(name, symbol);
|
||||
});
|
||||
}
|
||||
const callSignatures: Signature[] = usage.calls ? [getSignatureFromCalls(usage.calls)] : [];
|
||||
const constructSignatures: Signature[] = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : [];
|
||||
const stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false);
|
||||
return checker.createAnonymousType(/*symbol*/ undefined!, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217
|
||||
}
|
||||
|
||||
function inferNamedTypesFromProperties(usage: Usage): Type[] {
|
||||
if (!usage.properties || !usage.properties.size) return [];
|
||||
const types = builtins.filter(t => allPropertiesAreAssignableToUsage(t, usage));
|
||||
if (0 < types.length && types.length < 3) {
|
||||
return types.map(t => inferInstantiationFromUsage(t, usage));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function allPropertiesAreAssignableToUsage(type: Type, usage: Usage) {
|
||||
if (!usage.properties) return false;
|
||||
return !forEachEntry(usage.properties, (propUsage, name) => {
|
||||
const source = checker.getTypeOfPropertyOfType(type, name as string);
|
||||
if (!source) {
|
||||
return true;
|
||||
}
|
||||
if (propUsage.calls) {
|
||||
const sigs = checker.getSignaturesOfType(source, SignatureKind.Call);
|
||||
return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls));
|
||||
}
|
||||
else {
|
||||
return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* inference is limited to
|
||||
* 1. generic types with a single parameter
|
||||
* 2. inference to/from calls with a single signature
|
||||
*/
|
||||
function inferInstantiationFromUsage(type: Type, usage: Usage) {
|
||||
if (!(getObjectFlags(type) & ObjectFlags.Reference) || !usage.properties) {
|
||||
return type;
|
||||
}
|
||||
const generic = (type as TypeReference).target;
|
||||
const singleTypeParameter = singleOrUndefined(generic.typeParameters);
|
||||
if (!singleTypeParameter) return type;
|
||||
|
||||
const types: Type[] = [];
|
||||
usage.properties.forEach((propUsage, name) => {
|
||||
const genericPropertyType = checker.getTypeOfPropertyOfType(generic, name as string);
|
||||
Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference.");
|
||||
types.push(...inferTypeParameters(genericPropertyType!, combineFromUsage(propUsage), singleTypeParameter));
|
||||
});
|
||||
return builtinConstructors[type.symbol.escapedName as string](combineTypes(types));
|
||||
}
|
||||
|
||||
function inferTypeParameters(genericType: Type, usageType: Type, typeParameter: Type): readonly Type[] {
|
||||
if (genericType === typeParameter) {
|
||||
return [usageType];
|
||||
}
|
||||
else if (genericType.flags & TypeFlags.UnionOrIntersection) {
|
||||
return flatMap((genericType as UnionOrIntersectionType).types, t => inferTypeParameters(t, usageType, typeParameter));
|
||||
}
|
||||
else if (getObjectFlags(genericType) & ObjectFlags.Reference && getObjectFlags(usageType) & ObjectFlags.Reference) {
|
||||
// this is wrong because we need a reference to the targetType to, so we can check that it's also a reference
|
||||
const genericArgs = (genericType as TypeReference).typeArguments;
|
||||
const usageArgs = (usageType as TypeReference).typeArguments;
|
||||
const types = [];
|
||||
if (genericArgs && usageArgs) {
|
||||
for (let i = 0; i < genericArgs.length; i++) {
|
||||
if (usageArgs[i]) {
|
||||
types.push(...inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter));
|
||||
}
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
if (types.length) {
|
||||
const type = checker.getWidenedType(checker.getUnionType(types, UnionReduction.Subtype));
|
||||
return isRestParameter ? checker.createArrayType(type) : type;
|
||||
const genericSigs = checker.getSignaturesOfType(genericType, SignatureKind.Call);
|
||||
const usageSigs = checker.getSignaturesOfType(usageType, SignatureKind.Call);
|
||||
if (genericSigs.length === 1 && usageSigs.length === 1) {
|
||||
return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter);
|
||||
}
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
|
||||
function getSignatureFromCall(call: CallUsage): Signature {
|
||||
function inferFromSignatures(genericSig: Signature, usageSig: Signature, typeParameter: Type) {
|
||||
const types = [];
|
||||
for (let i = 0; i < genericSig.parameters.length; i++) {
|
||||
const genericParam = genericSig.parameters[i];
|
||||
const usageParam = usageSig.parameters[i];
|
||||
const isRest = genericSig.declaration && isRestParameter(genericSig.declaration.parameters[i]);
|
||||
if (!usageParam) {
|
||||
break;
|
||||
}
|
||||
let genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration);
|
||||
const elementType = isRest && checker.getElementTypeOfArrayType(genericParamType);
|
||||
if (elementType) {
|
||||
genericParamType = elementType;
|
||||
}
|
||||
const targetType = (usageParam as SymbolLinks).type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration);
|
||||
types.push(...inferTypeParameters(genericParamType, targetType, typeParameter));
|
||||
}
|
||||
const genericReturn = checker.getReturnTypeOfSignature(genericSig);
|
||||
const usageReturn = checker.getReturnTypeOfSignature(usageSig);
|
||||
types.push(...inferTypeParameters(genericReturn, usageReturn, typeParameter));
|
||||
return types;
|
||||
}
|
||||
|
||||
function getFunctionFromCalls(calls: CallUsage[]) {
|
||||
return checker.createAnonymousType(undefined!, createSymbolTable(), [getSignatureFromCalls(calls)], emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined);
|
||||
}
|
||||
|
||||
function getSignatureFromCalls(calls: CallUsage[]): Signature {
|
||||
const parameters: Symbol[] = [];
|
||||
for (let i = 0; i < call.argumentTypes.length; i++) {
|
||||
const length = Math.max(...calls.map(c => c.argumentTypes.length));
|
||||
for (let i = 0; i < length; i++) {
|
||||
const symbol = checker.createSymbol(SymbolFlags.FunctionScopedVariable, escapeLeadingUnderscores(`arg${i}`));
|
||||
symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(call.argumentTypes[i]));
|
||||
symbol.type = combineTypes(calls.map(call => call.argumentTypes[i] || checker.getUndefinedType()));
|
||||
if (calls.some(call => call.argumentTypes[i] === undefined)) {
|
||||
symbol.flags |= SymbolFlags.Optional;
|
||||
}
|
||||
parameters.push(symbol);
|
||||
}
|
||||
const returnType = unifyFromUsage(inferFromUsage(call.returnType), checker.getVoidType());
|
||||
const returnType = combineFromUsage(combineUsages(calls.map(call => call.return_)));
|
||||
// TODO: GH#18217
|
||||
return checker.createSignature(/*declaration*/ undefined!, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, call.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
|
||||
return checker.createSignature(/*declaration*/ undefined!, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
|
||||
}
|
||||
|
||||
function addCandidateType(usage: Usage, type: Type | undefined) {
|
||||
@@ -933,9 +1067,5 @@ namespace ts.codefix {
|
||||
(usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type);
|
||||
}
|
||||
}
|
||||
|
||||
function hasCalls(usage: Usage | undefined): boolean {
|
||||
return !!usage && !!usage.calls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,10 +1149,10 @@ namespace ts {
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getProgram,
|
||||
fileExists: host.fileExists && (f => host.fileExists!(f)),
|
||||
readFile: host.readFile && ((f, encoding) => host.readFile!(f, encoding)),
|
||||
getDocumentPositionMapper: host.getDocumentPositionMapper && ((generatedFileName, sourceFileName) => host.getDocumentPositionMapper!(generatedFileName, sourceFileName)),
|
||||
getSourceFileLike: host.getSourceFileLike && (f => host.getSourceFileLike!(f)),
|
||||
fileExists: maybeBind(host, host.fileExists),
|
||||
readFile: maybeBind(host, host.readFile),
|
||||
getDocumentPositionMapper: maybeBind(host, host.getDocumentPositionMapper),
|
||||
getSourceFileLike: maybeBind(host, host.getSourceFileLike),
|
||||
log
|
||||
});
|
||||
|
||||
@@ -1250,6 +1250,12 @@ namespace ts {
|
||||
if (host.resolveTypeReferenceDirectives) {
|
||||
compilerHost.resolveTypeReferenceDirectives = (...args) => host.resolveTypeReferenceDirectives!(...args);
|
||||
}
|
||||
if (host.setResolvedProjectReferenceCallbacks) {
|
||||
compilerHost.setResolvedProjectReferenceCallbacks = callbacks => host.setResolvedProjectReferenceCallbacks!(callbacks);
|
||||
}
|
||||
if (host.useSourceOfProjectReferenceRedirect) {
|
||||
compilerHost.useSourceOfProjectReferenceRedirect = () => host.useSourceOfProjectReferenceRedirect!();
|
||||
}
|
||||
|
||||
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
||||
const options: CreateProgramOptions = {
|
||||
|
||||
@@ -70,6 +70,11 @@ namespace ts {
|
||||
if (!sourceFile) return undefined;
|
||||
|
||||
const program = host.getProgram()!;
|
||||
// If this is source file of project reference source (instead of redirect) there is no generated position
|
||||
if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const options = program.getCompilerOptions();
|
||||
const outPath = options.outFile || options.out;
|
||||
|
||||
|
||||
@@ -234,6 +234,10 @@ namespace ts {
|
||||
getDocumentPositionMapper?(generatedFileName: string, sourceFileName?: string): DocumentPositionMapper | undefined;
|
||||
/* @internal */
|
||||
getSourceFileLike?(fileName: string): SourceFileLike | undefined;
|
||||
/* @internal */
|
||||
setResolvedProjectReferenceCallbacks?(callbacks: ResolvedProjectReferenceCallbacks): void;
|
||||
/* @internal */
|
||||
useSourceOfProjectReferenceRedirect?(): boolean;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@@ -146,6 +146,8 @@
|
||||
"unittests/tsserver/occurences.ts",
|
||||
"unittests/tsserver/openFile.ts",
|
||||
"unittests/tsserver/projectErrors.ts",
|
||||
"unittests/tsserver/projectReferenceCompileOnSave.ts",
|
||||
"unittests/tsserver/projectReferenceErrors.ts",
|
||||
"unittests/tsserver/projectReferences.ts",
|
||||
"unittests/tsserver/projects.ts",
|
||||
"unittests/tsserver/refactors.ts",
|
||||
|
||||
@@ -2,18 +2,12 @@ namespace ts.tscWatch {
|
||||
import projectsLocation = TestFSWithWatch.tsbuildProjectsLocation;
|
||||
import getFilePathInProject = TestFSWithWatch.getTsBuildProjectFilePath;
|
||||
import getFileFromProject = TestFSWithWatch.getTsBuildProjectFile;
|
||||
type TsBuildWatchSystem = WatchedSystem & { writtenFiles: Map<true>; };
|
||||
type TsBuildWatchSystem = TestFSWithWatch.TestServerHostTrackingWrittenFiles;
|
||||
|
||||
function createTsBuildWatchSystem(fileOrFolderList: readonly TestFSWithWatch.FileOrFolderOrSymLink[], params?: TestFSWithWatch.TestServerHostCreationParameters) {
|
||||
const host = createWatchedSystem(fileOrFolderList, params) as TsBuildWatchSystem;
|
||||
const originalWriteFile = host.writeFile;
|
||||
host.writtenFiles = createMap<true>();
|
||||
host.writeFile = (fileName, content) => {
|
||||
originalWriteFile.call(host, fileName, content);
|
||||
const path = host.toFullPath(fileName);
|
||||
host.writtenFiles.set(path, true);
|
||||
};
|
||||
return host;
|
||||
return TestFSWithWatch.changeToHostTrackingWrittenFiles(
|
||||
createWatchedSystem(fileOrFolderList, params)
|
||||
);
|
||||
}
|
||||
|
||||
export function createSolutionBuilder(system: WatchedSystem, rootNames: readonly string[], defaultOptions?: BuildOptions) {
|
||||
@@ -710,8 +704,8 @@ let x: string = 10;`);
|
||||
const coreIndexDts = projectFileName(SubProject.core, "index.d.ts");
|
||||
const coreAnotherModuleDts = projectFileName(SubProject.core, "anotherModule.d.ts");
|
||||
const logicIndexDts = projectFileName(SubProject.logic, "index.d.ts");
|
||||
const expectedWatchedFiles = () => [core[0], logic[0], ...tests, libFile].map(f => f.path).concat([coreIndexDts, coreAnotherModuleDts, logicIndexDts].map(f => f.toLowerCase()));
|
||||
const expectedWatchedDirectoriesRecursive = projectSystem.getTypeRootsFromLocation(projectPath(SubProject.tests));
|
||||
const expectedProjectFiles = () => [libFile, ...tests, ...logic.slice(1), ...core.slice(1, core.length - 1)].map(f => f.path);
|
||||
const expectedProgramFiles = () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, logicIndexDts];
|
||||
|
||||
function createSolutionAndWatchMode() {
|
||||
@@ -723,12 +717,19 @@ let x: string = 10;`);
|
||||
}
|
||||
|
||||
function verifyWatches(host: TsBuildWatchSystem, withTsserver?: boolean) {
|
||||
verifyWatchesOfProject(host, withTsserver ? expectedWatchedFiles().filter(f => f !== tests[1].path.toLowerCase()) : expectedWatchedFiles(), expectedWatchedDirectoriesRecursive);
|
||||
verifyWatchesOfProject(
|
||||
host,
|
||||
withTsserver ?
|
||||
[...core.slice(0, core.length - 1), ...logic, tests[0], libFile].map(f => f.path.toLowerCase()) :
|
||||
[core[0], logic[0], ...tests, libFile].map(f => f.path).concat([coreIndexDts, coreAnotherModuleDts, logicIndexDts].map(f => f.toLowerCase())),
|
||||
expectedWatchedDirectoriesRecursive
|
||||
);
|
||||
}
|
||||
|
||||
function verifyScenario(
|
||||
edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram>) => void,
|
||||
expectedFilesAfterEdit: () => readonly string[]
|
||||
expectedProgramFilesAfterEdit: () => readonly string[],
|
||||
expectedProjectFilesAfterEdit: () => readonly string[]
|
||||
) {
|
||||
it("with tsc-watch", () => {
|
||||
const { host, solutionBuilder, watch } = createSolutionAndWatchMode();
|
||||
@@ -737,7 +738,7 @@ let x: string = 10;`);
|
||||
|
||||
host.checkTimeoutQueueLengthAndRun(1);
|
||||
checkOutputErrorsIncremental(host, emptyArray);
|
||||
checkProgramActualFiles(watch(), expectedFilesAfterEdit());
|
||||
checkProgramActualFiles(watch(), expectedProgramFilesAfterEdit());
|
||||
|
||||
});
|
||||
|
||||
@@ -747,7 +748,7 @@ let x: string = 10;`);
|
||||
edit(host, solutionBuilder);
|
||||
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(service, tests[0].path, [tests[0].path, ...expectedFilesAfterEdit()]);
|
||||
checkProjectActualFiles(service, tests[0].path, expectedProjectFilesAfterEdit());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -777,7 +778,7 @@ function foo() {
|
||||
|
||||
// not ideal, but currently because of d.ts but no new file is written
|
||||
// There will be timeout queued even though file contents are same
|
||||
}, expectedProgramFiles);
|
||||
}, expectedProgramFiles, expectedProjectFiles);
|
||||
});
|
||||
|
||||
describe("non local edit in ts file, rebuilds in watch compilation", () => {
|
||||
@@ -787,7 +788,7 @@ export function gfoo() {
|
||||
}`);
|
||||
solutionBuilder.invalidateProject(logic[0].path.toLowerCase() as ResolvedConfigFilePath);
|
||||
solutionBuilder.buildNextInvalidatedProject();
|
||||
}, expectedProgramFiles);
|
||||
}, expectedProgramFiles, expectedProjectFiles);
|
||||
});
|
||||
|
||||
describe("change in project reference config file builds correctly", () => {
|
||||
@@ -798,7 +799,7 @@ export function gfoo() {
|
||||
}));
|
||||
solutionBuilder.invalidateProject(logic[0].path.toLowerCase() as ResolvedConfigFilePath, ConfigFileProgramReloadLevel.Full);
|
||||
solutionBuilder.buildNextInvalidatedProject();
|
||||
}, () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, projectFilePath(SubProject.logic, "decls/index.d.ts")]);
|
||||
}, () => [tests[1].path, libFile.path, coreIndexDts, coreAnotherModuleDts, projectFilePath(SubProject.logic, "decls/index.d.ts")], expectedProjectFiles);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -888,7 +889,9 @@ export function gfoo() {
|
||||
const aDts = dtsFile(multiFolder ? "a/index" : "a"), bDts = dtsFile(multiFolder ? "b/index" : "b");
|
||||
const expectedFiles = [jsFile(multiFolder ? "a/index" : "a"), aDts, jsFile(multiFolder ? "b/index" : "b"), bDts, jsFile(multiFolder ? "c/index" : "c")];
|
||||
const expectedProgramFiles = [cTs.path, libFile.path, aDts, refs.path, bDts];
|
||||
const expectedProjectFiles = [cTs.path, libFile.path, aTs.path, refs.path, bTs.path];
|
||||
const expectedWatchedFiles = expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase());
|
||||
const expectedProjectWatchedFiles = expectedProjectFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase());
|
||||
const expectedWatchedDirectories = multiFolder ? [
|
||||
getProjectPath(project).toLowerCase() // watches for directories created for resolution of b
|
||||
] : emptyArray;
|
||||
@@ -926,22 +929,29 @@ export function gfoo() {
|
||||
}
|
||||
|
||||
function verifyProject(host: TsBuildWatchSystem, service: projectSystem.TestProjectService, orphanInfos?: readonly string[]) {
|
||||
verifyServerState(host, service, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos);
|
||||
verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos });
|
||||
}
|
||||
|
||||
function verifyServerState(
|
||||
host: TsBuildWatchSystem,
|
||||
service: projectSystem.TestProjectService,
|
||||
expectedProgramFiles: readonly string[],
|
||||
expectedWatchedFiles: readonly string[],
|
||||
expectedWatchedDirectoriesRecursive: readonly string[],
|
||||
orphanInfos?: readonly string[]) {
|
||||
checkProjectActualFiles(service, cTsconfig.path, expectedProgramFiles.concat(cTsconfig.path));
|
||||
const watchedFiles = expectedWatchedFiles.filter(f => f !== cTs.path.toLowerCase());
|
||||
if (orphanInfos) {
|
||||
interface VerifyServerState {
|
||||
host: TsBuildWatchSystem;
|
||||
service: projectSystem.TestProjectService;
|
||||
expectedProjectFiles: readonly string[];
|
||||
expectedProjectWatchedFiles: readonly string[];
|
||||
expectedWatchedDirectoriesRecursive: readonly string[];
|
||||
orphanInfos?: readonly string[];
|
||||
}
|
||||
function verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos }: VerifyServerState) {
|
||||
checkProjectActualFiles(service, cTsconfig.path, expectedProjectFiles.concat(cTsconfig.path));
|
||||
const watchedFiles = expectedProjectWatchedFiles.filter(f => f !== cTs.path.toLowerCase());
|
||||
const actualOrphan = arrayFrom(mapDefinedIterator(
|
||||
service.filenameToScriptInfo.values(),
|
||||
v => v.containingProjects.length === 0 ? v.fileName : undefined
|
||||
));
|
||||
assert.equal(actualOrphan.length, orphanInfos ? orphanInfos.length : 0, `Orphans found: ${JSON.stringify(actualOrphan, /*replacer*/ undefined, " ")}`);
|
||||
if (orphanInfos && orphanInfos.length) {
|
||||
for (const orphan of orphanInfos) {
|
||||
const info = service.getScriptInfoForPath(orphan as Path);
|
||||
assert.isDefined(info);
|
||||
assert.isDefined(info, `${orphan} expected to be present. Actual: ${JSON.stringify(actualOrphan, /*replacer*/ undefined, " ")}`);
|
||||
assert.equal(info!.containingProjects.length, 0);
|
||||
watchedFiles.push(orphan);
|
||||
}
|
||||
@@ -949,16 +959,20 @@ export function gfoo() {
|
||||
verifyWatchesOfProject(host, watchedFiles, expectedWatchedDirectoriesRecursive, expectedWatchedDirectories);
|
||||
}
|
||||
|
||||
function verifyScenario(
|
||||
edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram>) => void,
|
||||
expectedEditErrors: readonly string[],
|
||||
expectedProgramFiles: readonly string[],
|
||||
expectedWatchedFiles: readonly string[],
|
||||
expectedWatchedDirectoriesRecursive: readonly string[],
|
||||
dependencies: readonly [string, readonly string[]][],
|
||||
revert?: (host: TsBuildWatchSystem) => void,
|
||||
orphanInfosAfterEdit?: readonly string[],
|
||||
orphanInfosAfterRevert?: readonly string[]) {
|
||||
interface VerifyScenario {
|
||||
edit: (host: TsBuildWatchSystem, solutionBuilder: SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram>) => void;
|
||||
expectedEditErrors: readonly string[];
|
||||
expectedProgramFiles: readonly string[];
|
||||
expectedProjectFiles: readonly string[];
|
||||
expectedWatchedFiles: readonly string[];
|
||||
expectedProjectWatchedFiles: readonly string[];
|
||||
expectedWatchedDirectoriesRecursive: readonly string[];
|
||||
dependencies: readonly [string, readonly string[]][];
|
||||
revert?: (host: TsBuildWatchSystem) => void;
|
||||
orphanInfosAfterEdit?: readonly string[];
|
||||
orphanInfosAfterRevert?: readonly string[];
|
||||
}
|
||||
function verifyScenario({ edit, expectedEditErrors, expectedProgramFiles, expectedProjectFiles, expectedWatchedFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, dependencies, revert, orphanInfosAfterEdit, orphanInfosAfterRevert }: VerifyScenario) {
|
||||
it("with tsc-watch", () => {
|
||||
const { host, solutionBuilder, watch } = createSolutionAndWatchMode();
|
||||
|
||||
@@ -985,7 +999,7 @@ export function gfoo() {
|
||||
edit(host, solutionBuilder);
|
||||
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
verifyServerState(host, service, expectedProgramFiles, expectedWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfosAfterEdit);
|
||||
verifyServerState({ host, service, expectedProjectFiles, expectedProjectWatchedFiles, expectedWatchedDirectoriesRecursive, orphanInfos: orphanInfosAfterEdit });
|
||||
|
||||
if (revert) {
|
||||
revert(host);
|
||||
@@ -1010,20 +1024,21 @@ export function gfoo() {
|
||||
});
|
||||
|
||||
describe("non local edit updates the program and watch correctly", () => {
|
||||
verifyScenario(
|
||||
(host, solutionBuilder) => {
|
||||
verifyScenario({
|
||||
edit: (host, solutionBuilder) => {
|
||||
// edit
|
||||
host.writeFile(bTs.path, `${bTs.content}
|
||||
export function gfoo() {
|
||||
}`);
|
||||
solutionBuilder.invalidateProject(bTsconfig.path.toLowerCase() as ResolvedConfigFilePath);
|
||||
host.writeFile(bTs.path, `${bTs.content}\nexport function gfoo() {\n}`);
|
||||
solutionBuilder.invalidateProject((bTsconfig.path.toLowerCase() as ResolvedConfigFilePath));
|
||||
solutionBuilder.buildNextInvalidatedProject();
|
||||
},
|
||||
emptyArray,
|
||||
expectedEditErrors: emptyArray,
|
||||
expectedProgramFiles,
|
||||
expectedProjectFiles,
|
||||
expectedWatchedFiles,
|
||||
expectedProjectWatchedFiles,
|
||||
expectedWatchedDirectoriesRecursive,
|
||||
defaultDependencies);
|
||||
dependencies: defaultDependencies
|
||||
});
|
||||
});
|
||||
|
||||
describe("edit on config file", () => {
|
||||
@@ -1032,30 +1047,32 @@ export function gfoo() {
|
||||
path: getFilePathInProject(project, "nrefs/a.d.ts"),
|
||||
content: refs.content
|
||||
};
|
||||
verifyScenario(
|
||||
host => {
|
||||
verifyScenario({
|
||||
edit: host => {
|
||||
const cTsConfigJson = JSON.parse(cTsconfig.content);
|
||||
host.ensureFileOrFolder(nrefs);
|
||||
cTsConfigJson.compilerOptions.paths = { "@ref/*": nrefsPath };
|
||||
host.writeFile(cTsconfig.path, JSON.stringify(cTsConfigJson));
|
||||
},
|
||||
emptyArray,
|
||||
expectedProgramFiles.map(nrefReplacer),
|
||||
expectedWatchedFiles.map(nrefReplacer),
|
||||
expectedWatchedDirectoriesRecursive.map(nrefReplacer),
|
||||
[
|
||||
expectedEditErrors: emptyArray,
|
||||
expectedProgramFiles: expectedProgramFiles.map(nrefReplacer),
|
||||
expectedProjectFiles: expectedProjectFiles.map(nrefReplacer),
|
||||
expectedWatchedFiles: expectedWatchedFiles.map(nrefReplacer),
|
||||
expectedProjectWatchedFiles: expectedProjectWatchedFiles.map(nrefReplacer),
|
||||
expectedWatchedDirectoriesRecursive: expectedWatchedDirectoriesRecursive.map(nrefReplacer),
|
||||
dependencies: [
|
||||
[aDts, [aDts]],
|
||||
[bDts, [bDts, aDts]],
|
||||
[nrefs.path, [nrefs.path]],
|
||||
[cTs.path, [cTs.path, nrefs.path, bDts]]
|
||||
],
|
||||
// revert the update
|
||||
host => host.writeFile(cTsconfig.path, cTsconfig.content),
|
||||
revert: host => host.writeFile(cTsconfig.path, cTsconfig.content),
|
||||
// AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[refs.path.toLowerCase()],
|
||||
orphanInfosAfterEdit: [refs.path.toLowerCase()],
|
||||
// AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[nrefs.path.toLowerCase()]
|
||||
);
|
||||
orphanInfosAfterRevert: [nrefs.path.toLowerCase()]
|
||||
});
|
||||
});
|
||||
|
||||
describe("edit in referenced config file", () => {
|
||||
@@ -1064,82 +1081,84 @@ export function gfoo() {
|
||||
content: "export declare class A {}"
|
||||
};
|
||||
const expectedProgramFiles = [cTs.path, bDts, nrefs.path, refs.path, libFile.path];
|
||||
const expectedProjectFiles = [cTs.path, bTs.path, nrefs.path, refs.path, libFile.path];
|
||||
const [, ...expectedWatchedDirectoriesRecursiveWithoutA] = expectedWatchedDirectoriesRecursive; // Not looking in a folder for resolution in multi folder scenario
|
||||
verifyScenario(
|
||||
host => {
|
||||
verifyScenario({
|
||||
edit: host => {
|
||||
const bTsConfigJson = JSON.parse(bTsconfig.content);
|
||||
host.ensureFileOrFolder(nrefs);
|
||||
bTsConfigJson.compilerOptions.paths = { "@ref/*": nrefsPath };
|
||||
host.writeFile(bTsconfig.path, JSON.stringify(bTsConfigJson));
|
||||
},
|
||||
emptyArray,
|
||||
expectedEditErrors: emptyArray,
|
||||
expectedProgramFiles,
|
||||
expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()),
|
||||
(multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive).concat(getFilePathInProject(project, "nrefs").toLowerCase()),
|
||||
[
|
||||
expectedProjectFiles,
|
||||
expectedWatchedFiles: expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()),
|
||||
expectedProjectWatchedFiles: expectedProjectFiles.concat(cTsconfig.path, bTsconfig.path, aTsconfig.path).map(s => s.toLowerCase()),
|
||||
expectedWatchedDirectoriesRecursive: (multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive).concat(getFilePathInProject(project, "nrefs").toLowerCase()),
|
||||
dependencies: [
|
||||
[nrefs.path, [nrefs.path]],
|
||||
[bDts, [bDts, nrefs.path]],
|
||||
[refs.path, [refs.path]],
|
||||
[cTs.path, [cTs.path, refs.path, bDts]],
|
||||
],
|
||||
// revert the update
|
||||
host => host.writeFile(bTsconfig.path, bTsconfig.content),
|
||||
revert: host => host.writeFile(bTsconfig.path, bTsconfig.content),
|
||||
// AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[aDts.toLowerCase()],
|
||||
orphanInfosAfterEdit: [aTs.path.toLowerCase()],
|
||||
// AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[nrefs.path.toLowerCase()]
|
||||
);
|
||||
orphanInfosAfterRevert: [nrefs.path.toLowerCase()]
|
||||
});
|
||||
});
|
||||
|
||||
describe("deleting referenced config file", () => {
|
||||
const expectedProgramFiles = [cTs.path, bTs.path, refs.path, libFile.path];
|
||||
const expectedWatchedFiles = expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path).map(s => s.toLowerCase());
|
||||
const [, ...expectedWatchedDirectoriesRecursiveWithoutA] = expectedWatchedDirectoriesRecursive; // Not looking in a folder for resolution in multi folder scenario
|
||||
// Resolutions should change now
|
||||
// Should map to b.ts instead with options from our own config
|
||||
verifyScenario(
|
||||
host => host.deleteFile(bTsconfig.path),
|
||||
[
|
||||
verifyScenario({
|
||||
edit: host => host.deleteFile(bTsconfig.path),
|
||||
expectedEditErrors: [
|
||||
`${multiFolder ? "c/tsconfig.json" : "tsconfig.c.json"}(9,21): error TS6053: File '/user/username/projects/transitiveReferences/${multiFolder ? "b" : "tsconfig.b.json"}' not found.\n`
|
||||
],
|
||||
expectedProgramFiles,
|
||||
expectedProgramFiles.concat(cTsconfig.path, bTsconfig.path).map(s => s.toLowerCase()),
|
||||
multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive,
|
||||
[
|
||||
expectedProjectFiles: expectedProgramFiles,
|
||||
expectedWatchedFiles,
|
||||
expectedProjectWatchedFiles: expectedWatchedFiles,
|
||||
expectedWatchedDirectoriesRecursive: multiFolder ? expectedWatchedDirectoriesRecursiveWithoutA : expectedWatchedDirectoriesRecursive,
|
||||
dependencies: [
|
||||
[bTs.path, [bTs.path, refs.path]],
|
||||
[refs.path, [refs.path]],
|
||||
[cTs.path, [cTs.path, refs.path, bTs.path]],
|
||||
],
|
||||
// revert the update
|
||||
host => host.writeFile(bTsconfig.path, bTsconfig.content),
|
||||
revert: host => host.writeFile(bTsconfig.path, bTsconfig.content),
|
||||
// AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[bDts.toLowerCase(), aDts.toLowerCase(), aTsconfig.path.toLowerCase()],
|
||||
// AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[bTs.path.toLowerCase()]
|
||||
);
|
||||
orphanInfosAfterEdit: [aTs.path.toLowerCase(), aTsconfig.path.toLowerCase()],
|
||||
});
|
||||
});
|
||||
|
||||
describe("deleting transitively referenced config file", () => {
|
||||
verifyScenario(
|
||||
host => host.deleteFile(aTsconfig.path),
|
||||
[
|
||||
verifyScenario({
|
||||
edit: host => host.deleteFile(aTsconfig.path),
|
||||
expectedEditErrors: [
|
||||
`${multiFolder ? "b/tsconfig.json" : "tsconfig.b.json"}(10,21): error TS6053: File '/user/username/projects/transitiveReferences/${multiFolder ? "a" : "tsconfig.a.json"}' not found.\n`
|
||||
],
|
||||
expectedProgramFiles.map(s => s.replace(aDts, aTs.path)),
|
||||
expectedWatchedFiles.map(s => s.replace(aDts.toLowerCase(), aTs.path.toLocaleLowerCase())),
|
||||
expectedProgramFiles: expectedProgramFiles.map(s => s.replace(aDts, aTs.path)),
|
||||
expectedProjectFiles,
|
||||
expectedWatchedFiles: expectedWatchedFiles.map(s => s.replace(aDts.toLowerCase(), aTs.path.toLocaleLowerCase())),
|
||||
expectedProjectWatchedFiles,
|
||||
expectedWatchedDirectoriesRecursive,
|
||||
[
|
||||
dependencies: [
|
||||
[aTs.path, [aTs.path]],
|
||||
[bDts, [bDts, aTs.path]],
|
||||
[refs.path, [refs.path]],
|
||||
[cTs.path, [cTs.path, refs.path, bDts]],
|
||||
],
|
||||
// revert the update
|
||||
host => host.writeFile(aTsconfig.path, aTsconfig.content),
|
||||
// AfterEdit:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[aDts.toLowerCase()],
|
||||
// AfterRevert:: Extra watched files on server since the script infos arent deleted till next file open
|
||||
[aTs.path.toLowerCase()]
|
||||
);
|
||||
revert: host => host.writeFile(aTsconfig.path, aTsconfig.content),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace ts.projectSystem {
|
||||
}
|
||||
|
||||
function verifyUserTsConfigProject(session: TestSession) {
|
||||
checkProjectActualFiles(session.getProjectService().configuredProjects.get(userTsconfig.path)!, [userTs.path, aDts.path, userTsconfig.path]);
|
||||
checkProjectActualFiles(session.getProjectService().configuredProjects.get(userTsconfig.path)!, [userTs.path, aTs.path, userTsconfig.path]);
|
||||
}
|
||||
|
||||
it("goToDefinition", () => {
|
||||
@@ -450,6 +450,13 @@ namespace ts.projectSystem {
|
||||
name: "function f(): void",
|
||||
},
|
||||
references: [
|
||||
makeReferenceEntry({
|
||||
file: aTs,
|
||||
text: "f",
|
||||
options: { index: 1 },
|
||||
contextText: "function f() {}",
|
||||
isDefinition: true
|
||||
}),
|
||||
{
|
||||
fileName: bTs.path,
|
||||
isDefinition: false,
|
||||
@@ -457,13 +464,6 @@ namespace ts.projectSystem {
|
||||
isWriteAccess: false,
|
||||
textSpan: { start: 0, length: 1 },
|
||||
},
|
||||
makeReferenceEntry({
|
||||
file: aTs,
|
||||
text: "f",
|
||||
options: { index: 1 },
|
||||
contextText: "function f() {}",
|
||||
isDefinition: true
|
||||
})
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -73,44 +73,64 @@ namespace ts.projectSystem {
|
||||
verifyEvent(project, `Change in config file detected`);
|
||||
});
|
||||
|
||||
it("when opening original location project", () => {
|
||||
const aDTs: File = {
|
||||
path: `${projectRoot}/a/a.d.ts`,
|
||||
content: `export declare class A {
|
||||
describe("when opening original location project", () => {
|
||||
it("with project references", () => {
|
||||
verify();
|
||||
});
|
||||
|
||||
it("when disableSourceOfProjectReferenceRedirect is true", () => {
|
||||
verify(/*disableSourceOfProjectReferenceRedirect*/ true);
|
||||
});
|
||||
|
||||
function verify(disableSourceOfProjectReferenceRedirect?: true) {
|
||||
const aDTs: File = {
|
||||
path: `${projectRoot}/a/a.d.ts`,
|
||||
content: `export declare class A {
|
||||
}
|
||||
//# sourceMappingURL=a.d.ts.map
|
||||
`
|
||||
};
|
||||
const aDTsMap: File = {
|
||||
path: `${projectRoot}/a/a.d.ts.map`,
|
||||
content: `{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["./a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;CAAI"}`
|
||||
};
|
||||
const bTs: File = {
|
||||
path: bTsPath,
|
||||
content: `import {A} from "../a/a"; new A();`
|
||||
};
|
||||
const configB: File = {
|
||||
path: configBPath,
|
||||
content: JSON.stringify({
|
||||
references: [{ path: "../a" }]
|
||||
})
|
||||
};
|
||||
};
|
||||
const aDTsMap: File = {
|
||||
path: `${projectRoot}/a/a.d.ts.map`,
|
||||
content: `{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["./a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;CAAI"}`
|
||||
};
|
||||
const bTs: File = {
|
||||
path: bTsPath,
|
||||
content: `import {A} from "../a/a"; new A();`
|
||||
};
|
||||
const configB: File = {
|
||||
path: configBPath,
|
||||
content: JSON.stringify({
|
||||
...(disableSourceOfProjectReferenceRedirect && {
|
||||
compilerOptions: {
|
||||
disableSourceOfProjectReferenceRedirect
|
||||
}
|
||||
}),
|
||||
references: [{ path: "../a" }]
|
||||
})
|
||||
};
|
||||
|
||||
const { service, session, verifyEventWithOpenTs, verifyEvent } = createSessionToVerifyEvent(files.concat(aDTs, aDTsMap, bTs, configB));
|
||||
verifyEventWithOpenTs(bTs, configB.path, 1);
|
||||
const { service, session, verifyEventWithOpenTs, verifyEvent } = createSessionToVerifyEvent(files.concat(aDTs, aDTsMap, bTs, configB));
|
||||
verifyEventWithOpenTs(bTs, configB.path, 1);
|
||||
|
||||
session.executeCommandSeq<protocol.ReferencesRequest>({
|
||||
command: protocol.CommandTypes.References,
|
||||
arguments: {
|
||||
file: bTs.path,
|
||||
...protocolLocationFromSubstring(bTs.content, "A()")
|
||||
}
|
||||
});
|
||||
session.executeCommandSeq<protocol.ReferencesRequest>({
|
||||
command: protocol.CommandTypes.References,
|
||||
arguments: {
|
||||
file: bTs.path,
|
||||
...protocolLocationFromSubstring(bTs.content, "A()")
|
||||
}
|
||||
});
|
||||
|
||||
checkNumberOfProjects(service, { configuredProjects: 2 });
|
||||
const project = service.configuredProjects.get(configA.path)!;
|
||||
assert.isDefined(project);
|
||||
verifyEvent(project, `Creating project for original file: ${aTs.path} for location: ${aDTs.path}`);
|
||||
checkNumberOfProjects(service, { configuredProjects: 2 });
|
||||
const project = service.configuredProjects.get(configA.path)!;
|
||||
assert.isDefined(project);
|
||||
verifyEvent(
|
||||
project,
|
||||
disableSourceOfProjectReferenceRedirect ?
|
||||
`Creating project for original file: ${aTs.path} for location: ${aDTs.path}` :
|
||||
`Creating project for original file: ${aTs.path}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
describe("with external projects and config files ", () => {
|
||||
|
||||
@@ -491,8 +491,8 @@ namespace ts.projectSystem {
|
||||
checkArray("Open files", arrayFrom(projectService.openFiles.keys(), path => projectService.getScriptInfoForPath(path as Path)!.fileName), expectedFiles.map(file => file.path));
|
||||
}
|
||||
|
||||
export function checkScriptInfos(projectService: server.ProjectService, expectedFiles: readonly string[]) {
|
||||
checkArray("ScriptInfos files", arrayFrom(projectService.filenameToScriptInfo.values(), info => info.fileName), expectedFiles);
|
||||
export function checkScriptInfos(projectService: server.ProjectService, expectedFiles: readonly string[], additionInfo?: string) {
|
||||
checkArray(`ScriptInfos files: ${additionInfo || ""}`, arrayFrom(projectService.filenameToScriptInfo.values(), info => info.fileName), expectedFiles);
|
||||
}
|
||||
|
||||
export function protocolLocationFromSubstring(str: string, substring: string): protocol.Location {
|
||||
@@ -501,7 +501,7 @@ namespace ts.projectSystem {
|
||||
return protocolToLocation(str)(start);
|
||||
}
|
||||
|
||||
function protocolToLocation(text: string): (pos: number) => protocol.Location {
|
||||
export function protocolToLocation(text: string): (pos: number) => protocol.Location {
|
||||
const lineStarts = computeLineStarts(text);
|
||||
return pos => {
|
||||
const x = computeLineAndCharacterOfPosition(lineStarts, pos);
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
namespace ts.projectSystem {
|
||||
describe("unittests:: tsserver:: with project references and compile on save", () => {
|
||||
const projectLocation = "/user/username/projects/myproject";
|
||||
const dependecyLocation = `${projectLocation}/dependency`;
|
||||
const usageLocation = `${projectLocation}/usage`;
|
||||
const dependencyTs: File = {
|
||||
path: `${dependecyLocation}/fns.ts`,
|
||||
content: `export function fn1() { }
|
||||
export function fn2() { }
|
||||
`
|
||||
};
|
||||
const dependencyConfig: File = {
|
||||
path: `${dependecyLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { composite: true, declarationDir: "../decls" },
|
||||
compileOnSave: true
|
||||
})
|
||||
};
|
||||
const usageTs: File = {
|
||||
path: `${usageLocation}/usage.ts`,
|
||||
content: `import {
|
||||
fn1,
|
||||
fn2,
|
||||
} from '../decls/fns'
|
||||
fn1();
|
||||
fn2();
|
||||
`
|
||||
};
|
||||
const usageConfig: File = {
|
||||
path: `${usageLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compileOnSave: true,
|
||||
references: [{ path: "../dependency" }]
|
||||
})
|
||||
};
|
||||
|
||||
interface VerifySingleScenarioWorker extends VerifySingleScenario {
|
||||
withProject: boolean;
|
||||
}
|
||||
function verifySingleScenarioWorker({
|
||||
withProject, scenario, openFiles, requestArgs, change, expectedResult
|
||||
}: VerifySingleScenarioWorker) {
|
||||
it(scenario, () => {
|
||||
const host = TestFSWithWatch.changeToHostTrackingWrittenFiles(
|
||||
createServerHost([dependencyTs, dependencyConfig, usageTs, usageConfig, libFile])
|
||||
);
|
||||
const session = createSession(host);
|
||||
openFilesForSession(openFiles(), session);
|
||||
const reqArgs = requestArgs();
|
||||
const {
|
||||
expectedAffected,
|
||||
expectedEmit: { expectedEmitSuccess, expectedFiles },
|
||||
expectedEmitOutput
|
||||
} = expectedResult(withProject);
|
||||
|
||||
if (change) {
|
||||
session.executeCommandSeq<protocol.CompileOnSaveAffectedFileListRequest>({
|
||||
command: protocol.CommandTypes.CompileOnSaveAffectedFileList,
|
||||
arguments: { file: dependencyTs.path }
|
||||
});
|
||||
const { file, insertString } = change();
|
||||
if (session.getProjectService().openFiles.has(file.path)) {
|
||||
const toLocation = protocolToLocation(file.content);
|
||||
const location = toLocation(file.content.length);
|
||||
session.executeCommandSeq<protocol.ChangeRequest>({
|
||||
command: protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: file.path,
|
||||
...location,
|
||||
endLine: location.line,
|
||||
endOffset: location.offset,
|
||||
insertString
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
host.writeFile(file.path, `${file.content}${insertString}`);
|
||||
}
|
||||
host.writtenFiles.clear();
|
||||
}
|
||||
|
||||
const args = withProject ? reqArgs : { file: reqArgs.file };
|
||||
// Verify CompileOnSaveAffectedFileList
|
||||
const actualAffectedFiles = session.executeCommandSeq<protocol.CompileOnSaveAffectedFileListRequest>({
|
||||
command: protocol.CommandTypes.CompileOnSaveAffectedFileList,
|
||||
arguments: args
|
||||
}).response as protocol.CompileOnSaveAffectedFileListSingleProject[];
|
||||
assert.deepEqual(actualAffectedFiles, expectedAffected, "Affected files");
|
||||
|
||||
// Verify CompileOnSaveEmit
|
||||
const actualEmit = session.executeCommandSeq<protocol.CompileOnSaveEmitFileRequest>({
|
||||
command: protocol.CommandTypes.CompileOnSaveEmitFile,
|
||||
arguments: args
|
||||
}).response;
|
||||
assert.deepEqual(actualEmit, expectedEmitSuccess, "Emit files");
|
||||
assert.equal(host.writtenFiles.size, expectedFiles.length);
|
||||
for (const file of expectedFiles) {
|
||||
assert.equal(host.readFile(file.path), file.content, `Expected to write ${file.path}`);
|
||||
assert.isTrue(host.writtenFiles.has(file.path), `${file.path} is newly written`);
|
||||
}
|
||||
|
||||
// Verify EmitOutput
|
||||
const { exportedModulesFromDeclarationEmit: _1, ...actualEmitOutput } = session.executeCommandSeq<protocol.EmitOutputRequest>({
|
||||
command: protocol.CommandTypes.EmitOutput,
|
||||
arguments: args
|
||||
}).response as EmitOutput;
|
||||
assert.deepEqual(actualEmitOutput, expectedEmitOutput, "Emit output");
|
||||
});
|
||||
}
|
||||
|
||||
interface VerifySingleScenario {
|
||||
scenario: string;
|
||||
openFiles: () => readonly File[];
|
||||
requestArgs: () => protocol.FileRequestArgs;
|
||||
skipWithoutProject?: boolean;
|
||||
change?: () => SingleScenarioChange;
|
||||
expectedResult: GetSingleScenarioResult;
|
||||
}
|
||||
function verifySingleScenario(scenario: VerifySingleScenario) {
|
||||
if (!scenario.skipWithoutProject) {
|
||||
describe("without specifying project file", () => {
|
||||
verifySingleScenarioWorker({
|
||||
withProject: false,
|
||||
...scenario
|
||||
});
|
||||
});
|
||||
}
|
||||
describe("with specifying project file", () => {
|
||||
verifySingleScenarioWorker({
|
||||
withProject: true,
|
||||
...scenario
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interface SingleScenarioExpectedEmit {
|
||||
expectedEmitSuccess: boolean;
|
||||
expectedFiles: readonly File[];
|
||||
}
|
||||
interface SingleScenarioResult {
|
||||
expectedAffected: protocol.CompileOnSaveAffectedFileListSingleProject[];
|
||||
expectedEmit: SingleScenarioExpectedEmit;
|
||||
expectedEmitOutput: EmitOutput;
|
||||
}
|
||||
type GetSingleScenarioResult = (withProject: boolean) => SingleScenarioResult;
|
||||
interface SingleScenarioChange {
|
||||
file: File;
|
||||
insertString: string;
|
||||
}
|
||||
interface ScenarioDetails {
|
||||
scenarioName: string;
|
||||
requestArgs: () => protocol.FileRequestArgs;
|
||||
skipWithoutProject?: boolean;
|
||||
initial: GetSingleScenarioResult;
|
||||
localChangeToDependency: GetSingleScenarioResult;
|
||||
localChangeToUsage: GetSingleScenarioResult;
|
||||
changeToDependency: GetSingleScenarioResult;
|
||||
changeToUsage: GetSingleScenarioResult;
|
||||
}
|
||||
interface VerifyScenario {
|
||||
openFiles: () => readonly File[];
|
||||
scenarios: readonly ScenarioDetails[];
|
||||
}
|
||||
|
||||
const localChange = "function fn3() { }";
|
||||
const change = `export ${localChange}`;
|
||||
const changeJs = `function fn3() { }
|
||||
exports.fn3 = fn3;`;
|
||||
const changeDts = "export declare function fn3(): void;";
|
||||
function verifyScenario({ openFiles, scenarios }: VerifyScenario) {
|
||||
for (const {
|
||||
scenarioName, requestArgs, skipWithoutProject, initial,
|
||||
localChangeToDependency, localChangeToUsage,
|
||||
changeToDependency, changeToUsage
|
||||
} of scenarios) {
|
||||
describe(scenarioName, () => {
|
||||
verifySingleScenario({
|
||||
scenario: "with initial file open",
|
||||
openFiles,
|
||||
requestArgs,
|
||||
skipWithoutProject,
|
||||
expectedResult: initial
|
||||
});
|
||||
|
||||
verifySingleScenario({
|
||||
scenario: "with local change to dependency",
|
||||
openFiles,
|
||||
requestArgs,
|
||||
skipWithoutProject,
|
||||
change: () => ({ file: dependencyTs, insertString: localChange }),
|
||||
expectedResult: localChangeToDependency
|
||||
});
|
||||
|
||||
verifySingleScenario({
|
||||
scenario: "with local change to usage",
|
||||
openFiles,
|
||||
requestArgs,
|
||||
skipWithoutProject,
|
||||
change: () => ({ file: usageTs, insertString: localChange }),
|
||||
expectedResult: localChangeToUsage
|
||||
});
|
||||
|
||||
verifySingleScenario({
|
||||
scenario: "with change to dependency",
|
||||
openFiles,
|
||||
requestArgs,
|
||||
skipWithoutProject,
|
||||
change: () => ({ file: dependencyTs, insertString: change }),
|
||||
expectedResult: changeToDependency
|
||||
});
|
||||
|
||||
verifySingleScenario({
|
||||
scenario: "with change to usage",
|
||||
openFiles,
|
||||
requestArgs,
|
||||
skipWithoutProject,
|
||||
change: () => ({ file: usageTs, insertString: change }),
|
||||
expectedResult: changeToUsage
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function expectedAffectedFiles(config: File, fileNames: File[]): protocol.CompileOnSaveAffectedFileListSingleProject {
|
||||
return {
|
||||
projectFileName: config.path,
|
||||
fileNames: fileNames.map(f => f.path),
|
||||
projectUsesOutFile: false
|
||||
};
|
||||
}
|
||||
|
||||
function expectedUsageEmit(appendJsText?: string): SingleScenarioExpectedEmit {
|
||||
const appendJs = appendJsText ? `${appendJsText}
|
||||
` : "";
|
||||
return {
|
||||
expectedEmitSuccess: true,
|
||||
expectedFiles: [{
|
||||
path: `${usageLocation}/usage.js`,
|
||||
content: `"use strict";
|
||||
exports.__esModule = true;
|
||||
var fns_1 = require("../decls/fns");
|
||||
fns_1.fn1();
|
||||
fns_1.fn2();
|
||||
${appendJs}`
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
function expectedEmitOutput({ expectedFiles }: SingleScenarioExpectedEmit): EmitOutput {
|
||||
return {
|
||||
outputFiles: expectedFiles.map(({ path, content }) => ({
|
||||
name: path,
|
||||
text: content,
|
||||
writeByteOrderMark: false
|
||||
})),
|
||||
emitSkipped: false
|
||||
};
|
||||
}
|
||||
|
||||
function expectedUsageEmitOutput(appendJsText?: string): EmitOutput {
|
||||
return expectedEmitOutput(expectedUsageEmit(appendJsText));
|
||||
}
|
||||
|
||||
function noEmit(): SingleScenarioExpectedEmit {
|
||||
return {
|
||||
expectedEmitSuccess: false,
|
||||
expectedFiles: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
function noEmitOutput(): EmitOutput {
|
||||
return {
|
||||
emitSkipped: true,
|
||||
outputFiles: []
|
||||
};
|
||||
}
|
||||
|
||||
function expectedDependencyEmit(appendJsText?: string, appendDtsText?: string): SingleScenarioExpectedEmit {
|
||||
const appendJs = appendJsText ? `${appendJsText}
|
||||
` : "";
|
||||
const appendDts = appendDtsText ? `${appendDtsText}
|
||||
` : "";
|
||||
return {
|
||||
expectedEmitSuccess: true,
|
||||
expectedFiles: [
|
||||
{
|
||||
path: `${dependecyLocation}/fns.js`,
|
||||
content: `"use strict";
|
||||
exports.__esModule = true;
|
||||
function fn1() { }
|
||||
exports.fn1 = fn1;
|
||||
function fn2() { }
|
||||
exports.fn2 = fn2;
|
||||
${appendJs}`
|
||||
},
|
||||
{
|
||||
path: `${projectLocation}/decls/fns.d.ts`,
|
||||
content: `export declare function fn1(): void;
|
||||
export declare function fn2(): void;
|
||||
${appendDts}`
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function expectedDependencyEmitOutput(appendJsText?: string, appendDtsText?: string): EmitOutput {
|
||||
return expectedEmitOutput(expectedDependencyEmit(appendJsText, appendDtsText));
|
||||
}
|
||||
|
||||
function scenarioDetailsOfUsage(isDependencyOpen?: boolean): ScenarioDetails[] {
|
||||
return [
|
||||
{
|
||||
scenarioName: "Of usageTs",
|
||||
requestArgs: () => ({ file: usageTs.path, projectFileName: usageConfig.path }),
|
||||
initial: () => initialUsageTs(),
|
||||
// no change to usage so same as initial only usage file
|
||||
localChangeToDependency: () => initialUsageTs(),
|
||||
localChangeToUsage: () => initialUsageTs(localChange),
|
||||
changeToDependency: () => initialUsageTs(),
|
||||
changeToUsage: () => initialUsageTs(changeJs)
|
||||
},
|
||||
{
|
||||
scenarioName: "Of dependencyTs in usage project",
|
||||
requestArgs: () => ({ file: dependencyTs.path, projectFileName: usageConfig.path }),
|
||||
skipWithoutProject: !!isDependencyOpen,
|
||||
initial: () => initialDependencyTs(),
|
||||
localChangeToDependency: () => initialDependencyTs(/*noUsageFiles*/ true),
|
||||
localChangeToUsage: () => initialDependencyTs(/*noUsageFiles*/ true),
|
||||
changeToDependency: () => initialDependencyTs(),
|
||||
changeToUsage: () => initialDependencyTs(/*noUsageFiles*/ true)
|
||||
}
|
||||
];
|
||||
|
||||
function initialUsageTs(jsText?: string) {
|
||||
return {
|
||||
expectedAffected: [
|
||||
expectedAffectedFiles(usageConfig, [usageTs])
|
||||
],
|
||||
expectedEmit: expectedUsageEmit(jsText),
|
||||
expectedEmitOutput: expectedUsageEmitOutput(jsText)
|
||||
};
|
||||
}
|
||||
|
||||
function initialDependencyTs(noUsageFiles?: true) {
|
||||
return {
|
||||
expectedAffected: [
|
||||
expectedAffectedFiles(usageConfig, noUsageFiles ? [] : [usageTs])
|
||||
],
|
||||
expectedEmit: noEmit(),
|
||||
expectedEmitOutput: noEmitOutput()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function scenarioDetailsOfDependencyWhenOpen(): ScenarioDetails {
|
||||
return {
|
||||
scenarioName: "Of dependencyTs",
|
||||
requestArgs: () => ({ file: dependencyTs.path, projectFileName: dependencyConfig.path }),
|
||||
initial,
|
||||
localChangeToDependency: withProject => ({
|
||||
expectedAffected: withProject ?
|
||||
[
|
||||
expectedAffectedFiles(dependencyConfig, [dependencyTs])
|
||||
] :
|
||||
[
|
||||
expectedAffectedFiles(usageConfig, []),
|
||||
expectedAffectedFiles(dependencyConfig, [dependencyTs])
|
||||
],
|
||||
expectedEmit: expectedDependencyEmit(localChange),
|
||||
expectedEmitOutput: expectedDependencyEmitOutput(localChange)
|
||||
}),
|
||||
localChangeToUsage: withProject => initial(withProject, /*noUsageFiles*/ true),
|
||||
changeToDependency: withProject => initial(withProject, /*noUsageFiles*/ undefined, changeJs, changeDts),
|
||||
changeToUsage: withProject => initial(withProject, /*noUsageFiles*/ true)
|
||||
};
|
||||
|
||||
function initial(withProject: boolean, noUsageFiles?: true, appendJs?: string, appendDts?: string): SingleScenarioResult {
|
||||
return {
|
||||
expectedAffected: withProject ?
|
||||
[
|
||||
expectedAffectedFiles(dependencyConfig, [dependencyTs])
|
||||
] :
|
||||
[
|
||||
expectedAffectedFiles(usageConfig, noUsageFiles ? [] : [usageTs]),
|
||||
expectedAffectedFiles(dependencyConfig, [dependencyTs])
|
||||
],
|
||||
expectedEmit: expectedDependencyEmit(appendJs, appendDts),
|
||||
expectedEmitOutput: expectedDependencyEmitOutput(appendJs, appendDts)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
describe("when dependency project is not open", () => {
|
||||
verifyScenario({
|
||||
openFiles: () => [usageTs],
|
||||
scenarios: scenarioDetailsOfUsage()
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the depedency file is open", () => {
|
||||
verifyScenario({
|
||||
openFiles: () => [usageTs, dependencyTs],
|
||||
scenarios: [
|
||||
...scenarioDetailsOfUsage(/*isDependencyOpen*/ true),
|
||||
scenarioDetailsOfDependencyWhenOpen(),
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
namespace ts.projectSystem {
|
||||
describe("unittests:: tsserver:: with project references and error reporting", () => {
|
||||
const projectLocation = "/user/username/projects/myproject";
|
||||
const dependecyLocation = `${projectLocation}/dependency`;
|
||||
const usageLocation = `${projectLocation}/usage`;
|
||||
|
||||
interface CheckErrorsInFile {
|
||||
session: TestSession;
|
||||
host: TestServerHost;
|
||||
expected: GetErrDiagnostics;
|
||||
expectedSequenceId?: number;
|
||||
}
|
||||
function checkErrorsInFile({ session, host, expected: { file, syntax, semantic, suggestion }, expectedSequenceId }: CheckErrorsInFile) {
|
||||
host.checkTimeoutQueueLengthAndRun(1);
|
||||
checkErrorMessage(session, "syntaxDiag", { file: file.path, diagnostics: syntax });
|
||||
session.clearMessages();
|
||||
|
||||
host.runQueuedImmediateCallbacks(1);
|
||||
checkErrorMessage(session, "semanticDiag", { file: file.path, diagnostics: semantic });
|
||||
session.clearMessages();
|
||||
|
||||
host.runQueuedImmediateCallbacks(1);
|
||||
checkErrorMessage(session, "suggestionDiag", { file: file.path, diagnostics: suggestion });
|
||||
if (expectedSequenceId !== undefined) {
|
||||
checkCompleteEvent(session, 2, expectedSequenceId);
|
||||
}
|
||||
session.clearMessages();
|
||||
}
|
||||
|
||||
interface CheckAllErrors {
|
||||
session: TestSession;
|
||||
host: TestServerHost;
|
||||
expected: readonly GetErrDiagnostics[];
|
||||
expectedSequenceId: number;
|
||||
}
|
||||
function checkAllErrors({ session, host, expected, expectedSequenceId }: CheckAllErrors) {
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
checkErrorsInFile({
|
||||
session,
|
||||
host,
|
||||
expected: expected[i],
|
||||
expectedSequenceId: i === expected.length - 1 ? expectedSequenceId : undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function verifyErrorsUsingGeterr({ allFiles, openFiles, expectedGetErr }: VerifyScenario) {
|
||||
it("verifies the errors in open file", () => {
|
||||
const host = createServerHost([...allFiles(), libFile]);
|
||||
const session = createSession(host, { canUseEvents: true, });
|
||||
openFilesForSession(openFiles(), session);
|
||||
|
||||
session.clearMessages();
|
||||
const expectedSequenceId = session.getNextSeq();
|
||||
const expected = expectedGetErr();
|
||||
session.executeCommandSeq<protocol.GeterrRequest>({
|
||||
command: protocol.CommandTypes.Geterr,
|
||||
arguments: {
|
||||
delay: 0,
|
||||
files: expected.map(f => f.file.path)
|
||||
}
|
||||
});
|
||||
|
||||
checkAllErrors({ session, host, expected, expectedSequenceId });
|
||||
});
|
||||
}
|
||||
|
||||
function verifyErrorsUsingGeterrForProject({ allFiles, openFiles, expectedGetErrForProject }: VerifyScenario) {
|
||||
it("verifies the errors in projects", () => {
|
||||
const host = createServerHost([...allFiles(), libFile]);
|
||||
const session = createSession(host, { canUseEvents: true, });
|
||||
openFilesForSession(openFiles(), session);
|
||||
|
||||
session.clearMessages();
|
||||
for (const expected of expectedGetErrForProject()) {
|
||||
const expectedSequenceId = session.getNextSeq();
|
||||
session.executeCommandSeq<protocol.GeterrForProjectRequest>({
|
||||
command: protocol.CommandTypes.GeterrForProject,
|
||||
arguments: {
|
||||
delay: 0,
|
||||
file: expected.project
|
||||
}
|
||||
});
|
||||
|
||||
checkAllErrors({ session, host, expected: expected.errors, expectedSequenceId });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verifyErrorsUsingSyncMethods({ allFiles, openFiles, expectedSyncDiagnostics }: VerifyScenario) {
|
||||
it("verifies the errors using sync commands", () => {
|
||||
const host = createServerHost([...allFiles(), libFile]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession(openFiles(), session);
|
||||
for (const { file, project, syntax, semantic, suggestion } of expectedSyncDiagnostics()) {
|
||||
const actualSyntax = session.executeCommandSeq<protocol.SyntacticDiagnosticsSyncRequest>({
|
||||
command: protocol.CommandTypes.SyntacticDiagnosticsSync,
|
||||
arguments: {
|
||||
file: file.path,
|
||||
projectFileName: project
|
||||
}
|
||||
}).response as protocol.Diagnostic[];
|
||||
assert.deepEqual(actualSyntax, syntax, `Syntax diagnostics for file: ${file.path}, project: ${project}`);
|
||||
const actualSemantic = session.executeCommandSeq<protocol.SemanticDiagnosticsSyncRequest>({
|
||||
command: protocol.CommandTypes.SemanticDiagnosticsSync,
|
||||
arguments: {
|
||||
file: file.path,
|
||||
projectFileName: project
|
||||
}
|
||||
}).response as protocol.Diagnostic[];
|
||||
assert.deepEqual(actualSemantic, semantic, `Semantic diagnostics for file: ${file.path}, project: ${project}`);
|
||||
const actualSuggestion = session.executeCommandSeq<protocol.SuggestionDiagnosticsSyncRequest>({
|
||||
command: protocol.CommandTypes.SuggestionDiagnosticsSync,
|
||||
arguments: {
|
||||
file: file.path,
|
||||
projectFileName: project
|
||||
}
|
||||
}).response as protocol.Diagnostic[];
|
||||
assert.deepEqual(actualSuggestion, suggestion, `Suggestion diagnostics for file: ${file.path}, project: ${project}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verifyConfigFileErrors({ allFiles, openFiles, expectedConfigFileDiagEvents }: VerifyScenario) {
|
||||
it("verify config file errors", () => {
|
||||
const host = createServerHost([...allFiles(), libFile]);
|
||||
const { session, events } = createSessionWithEventTracking<server.ConfigFileDiagEvent>(host, server.ConfigFileDiagEvent);
|
||||
|
||||
for (const file of openFiles()) {
|
||||
session.executeCommandSeq<protocol.OpenRequest>({
|
||||
command: protocol.CommandTypes.Open,
|
||||
arguments: { file: file.path }
|
||||
});
|
||||
}
|
||||
|
||||
assert.deepEqual(events, expectedConfigFileDiagEvents().map(data => ({
|
||||
eventName: server.ConfigFileDiagEvent,
|
||||
data
|
||||
})));
|
||||
});
|
||||
}
|
||||
|
||||
interface GetErrDiagnostics {
|
||||
file: File;
|
||||
syntax: protocol.Diagnostic[];
|
||||
semantic: protocol.Diagnostic[];
|
||||
suggestion: protocol.Diagnostic[];
|
||||
}
|
||||
interface GetErrForProjectDiagnostics {
|
||||
project: string;
|
||||
errors: readonly GetErrDiagnostics[];
|
||||
}
|
||||
interface SyncDiagnostics extends GetErrDiagnostics {
|
||||
project?: string;
|
||||
}
|
||||
interface VerifyScenario {
|
||||
allFiles: () => readonly File[];
|
||||
openFiles: () => readonly File[];
|
||||
expectedGetErr: () => readonly GetErrDiagnostics[];
|
||||
expectedGetErrForProject: () => readonly GetErrForProjectDiagnostics[];
|
||||
expectedSyncDiagnostics: () => readonly SyncDiagnostics[];
|
||||
expectedConfigFileDiagEvents: () => readonly server.ConfigFileDiagEvent["data"][];
|
||||
}
|
||||
function verifyScenario(scenario: VerifyScenario) {
|
||||
verifyErrorsUsingGeterr(scenario);
|
||||
verifyErrorsUsingGeterrForProject(scenario);
|
||||
verifyErrorsUsingSyncMethods(scenario);
|
||||
verifyConfigFileErrors(scenario);
|
||||
}
|
||||
|
||||
function emptyDiagnostics(file: File): GetErrDiagnostics {
|
||||
return {
|
||||
file,
|
||||
syntax: emptyArray,
|
||||
semantic: emptyArray,
|
||||
suggestion: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
function syncDiagnostics(diagnostics: GetErrDiagnostics, project: string): SyncDiagnostics {
|
||||
return { project, ...diagnostics };
|
||||
}
|
||||
|
||||
interface VerifyUsageAndDependency {
|
||||
allFiles: readonly [File, File, File, File]; // dependencyTs, dependencyConfig, usageTs, usageConfig
|
||||
usageDiagnostics(): GetErrDiagnostics;
|
||||
dependencyDiagnostics(): GetErrDiagnostics;
|
||||
|
||||
}
|
||||
function verifyUsageAndDependency({ allFiles, usageDiagnostics, dependencyDiagnostics }: VerifyUsageAndDependency) {
|
||||
const [dependencyTs, dependencyConfig, usageTs, usageConfig] = allFiles;
|
||||
function usageProjectDiagnostics(): GetErrForProjectDiagnostics {
|
||||
return {
|
||||
project: usageTs.path,
|
||||
errors: [
|
||||
usageDiagnostics(),
|
||||
emptyDiagnostics(dependencyTs)
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function dependencyProjectDiagnostics(): GetErrForProjectDiagnostics {
|
||||
return {
|
||||
project: dependencyTs.path,
|
||||
errors: [
|
||||
dependencyDiagnostics()
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function usageConfigDiag(): server.ConfigFileDiagEvent["data"] {
|
||||
return {
|
||||
triggerFile: usageTs.path,
|
||||
configFileName: usageConfig.path,
|
||||
diagnostics: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
function dependencyConfigDiag(): server.ConfigFileDiagEvent["data"] {
|
||||
return {
|
||||
triggerFile: dependencyTs.path,
|
||||
configFileName: dependencyConfig.path,
|
||||
diagnostics: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
describe("when dependency project is not open", () => {
|
||||
verifyScenario({
|
||||
allFiles: () => allFiles,
|
||||
openFiles: () => [usageTs],
|
||||
expectedGetErr: () => [
|
||||
usageDiagnostics()
|
||||
],
|
||||
expectedGetErrForProject: () => [
|
||||
usageProjectDiagnostics(),
|
||||
{
|
||||
project: dependencyTs.path,
|
||||
errors: [
|
||||
emptyDiagnostics(dependencyTs),
|
||||
usageDiagnostics()
|
||||
]
|
||||
}
|
||||
],
|
||||
expectedSyncDiagnostics: () => [
|
||||
// Without project
|
||||
usageDiagnostics(),
|
||||
emptyDiagnostics(dependencyTs),
|
||||
// With project
|
||||
syncDiagnostics(usageDiagnostics(), usageConfig.path),
|
||||
syncDiagnostics(emptyDiagnostics(dependencyTs), usageConfig.path),
|
||||
],
|
||||
expectedConfigFileDiagEvents: () => [
|
||||
usageConfigDiag()
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the depedency file is open", () => {
|
||||
verifyScenario({
|
||||
allFiles: () => allFiles,
|
||||
openFiles: () => [usageTs, dependencyTs],
|
||||
expectedGetErr: () => [
|
||||
usageDiagnostics(),
|
||||
dependencyDiagnostics(),
|
||||
],
|
||||
expectedGetErrForProject: () => [
|
||||
usageProjectDiagnostics(),
|
||||
dependencyProjectDiagnostics()
|
||||
],
|
||||
expectedSyncDiagnostics: () => [
|
||||
// Without project
|
||||
usageDiagnostics(),
|
||||
dependencyDiagnostics(),
|
||||
// With project
|
||||
syncDiagnostics(usageDiagnostics(), usageConfig.path),
|
||||
syncDiagnostics(emptyDiagnostics(dependencyTs), usageConfig.path),
|
||||
syncDiagnostics(dependencyDiagnostics(), dependencyConfig.path),
|
||||
],
|
||||
expectedConfigFileDiagEvents: () => [
|
||||
usageConfigDiag(),
|
||||
dependencyConfigDiag()
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe("with module scenario", () => {
|
||||
const dependencyTs: File = {
|
||||
path: `${dependecyLocation}/fns.ts`,
|
||||
content: `export function fn1() { }
|
||||
export function fn2() { }
|
||||
// Introduce error for fnErr import in main
|
||||
// export function fnErr() { }
|
||||
// Error in dependency ts file
|
||||
export let x: string = 10;`
|
||||
};
|
||||
const dependencyConfig: File = {
|
||||
path: `${dependecyLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true, declarationDir: "../decls" } })
|
||||
};
|
||||
const usageTs: File = {
|
||||
path: `${usageLocation}/usage.ts`,
|
||||
content: `import {
|
||||
fn1,
|
||||
fn2,
|
||||
fnErr
|
||||
} from '../decls/fns'
|
||||
fn1();
|
||||
fn2();
|
||||
fnErr();
|
||||
`
|
||||
};
|
||||
const usageConfig: File = {
|
||||
path: `${usageLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { composite: true },
|
||||
references: [{ path: "../dependency" }]
|
||||
})
|
||||
};
|
||||
function usageDiagnostics(): GetErrDiagnostics {
|
||||
return {
|
||||
file: usageTs,
|
||||
syntax: emptyArray,
|
||||
semantic: [
|
||||
createDiagnostic(
|
||||
{ line: 4, offset: 5 },
|
||||
{ line: 4, offset: 10 },
|
||||
Diagnostics.Module_0_has_no_exported_member_1,
|
||||
[`"../dependency/fns"`, "fnErr"],
|
||||
"error",
|
||||
)
|
||||
],
|
||||
suggestion: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
function dependencyDiagnostics(): GetErrDiagnostics {
|
||||
return {
|
||||
file: dependencyTs,
|
||||
syntax: emptyArray,
|
||||
semantic: [
|
||||
createDiagnostic(
|
||||
{ line: 6, offset: 12 },
|
||||
{ line: 6, offset: 13 },
|
||||
Diagnostics.Type_0_is_not_assignable_to_type_1,
|
||||
["10", "string"],
|
||||
"error",
|
||||
)
|
||||
],
|
||||
suggestion: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
verifyUsageAndDependency({
|
||||
allFiles: [dependencyTs, dependencyConfig, usageTs, usageConfig],
|
||||
usageDiagnostics,
|
||||
dependencyDiagnostics
|
||||
});
|
||||
});
|
||||
|
||||
describe("with non module --out", () => {
|
||||
const dependencyTs: File = {
|
||||
path: `${dependecyLocation}/fns.ts`,
|
||||
content: `function fn1() { }
|
||||
function fn2() { }
|
||||
// Introduce error for fnErr import in main
|
||||
// function fnErr() { }
|
||||
// Error in dependency ts file
|
||||
let x: string = 10;`
|
||||
};
|
||||
const dependencyConfig: File = {
|
||||
path: `${dependecyLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true, outFile: "../dependency.js" } })
|
||||
};
|
||||
const usageTs: File = {
|
||||
path: `${usageLocation}/usage.ts`,
|
||||
content: `fn1();
|
||||
fn2();
|
||||
fnErr();
|
||||
`
|
||||
};
|
||||
const usageConfig: File = {
|
||||
path: `${usageLocation}/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { composite: true, outFile: "../usage.js" },
|
||||
references: [{ path: "../dependency" }]
|
||||
})
|
||||
};
|
||||
function usageDiagnostics(): GetErrDiagnostics {
|
||||
return {
|
||||
file: usageTs,
|
||||
syntax: emptyArray,
|
||||
semantic: [
|
||||
createDiagnostic(
|
||||
{ line: 3, offset: 1 },
|
||||
{ line: 3, offset: 6 },
|
||||
Diagnostics.Cannot_find_name_0,
|
||||
["fnErr"],
|
||||
"error",
|
||||
)
|
||||
],
|
||||
suggestion: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
function dependencyDiagnostics(): GetErrDiagnostics {
|
||||
return {
|
||||
file: dependencyTs,
|
||||
syntax: emptyArray,
|
||||
semantic: [
|
||||
createDiagnostic(
|
||||
{ line: 6, offset: 5 },
|
||||
{ line: 6, offset: 6 },
|
||||
Diagnostics.Type_0_is_not_assignable_to_type_1,
|
||||
["10", "string"],
|
||||
"error",
|
||||
)
|
||||
],
|
||||
suggestion: emptyArray
|
||||
};
|
||||
}
|
||||
|
||||
verifyUsageAndDependency({
|
||||
allFiles: [dependencyTs, dependencyConfig, usageTs, usageConfig],
|
||||
usageDiagnostics,
|
||||
dependencyDiagnostics
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+270
-226
@@ -73,7 +73,7 @@ declare namespace ts {
|
||||
end: number;
|
||||
}
|
||||
export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
|
||||
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
|
||||
export enum SyntaxKind {
|
||||
Unknown = 0,
|
||||
@@ -198,206 +198,207 @@ declare namespace ts {
|
||||
YieldKeyword = 118,
|
||||
AbstractKeyword = 119,
|
||||
AsKeyword = 120,
|
||||
AnyKeyword = 121,
|
||||
AsyncKeyword = 122,
|
||||
AwaitKeyword = 123,
|
||||
BooleanKeyword = 124,
|
||||
ConstructorKeyword = 125,
|
||||
DeclareKeyword = 126,
|
||||
GetKeyword = 127,
|
||||
InferKeyword = 128,
|
||||
IsKeyword = 129,
|
||||
KeyOfKeyword = 130,
|
||||
ModuleKeyword = 131,
|
||||
NamespaceKeyword = 132,
|
||||
NeverKeyword = 133,
|
||||
ReadonlyKeyword = 134,
|
||||
RequireKeyword = 135,
|
||||
NumberKeyword = 136,
|
||||
ObjectKeyword = 137,
|
||||
SetKeyword = 138,
|
||||
StringKeyword = 139,
|
||||
SymbolKeyword = 140,
|
||||
TypeKeyword = 141,
|
||||
UndefinedKeyword = 142,
|
||||
UniqueKeyword = 143,
|
||||
UnknownKeyword = 144,
|
||||
FromKeyword = 145,
|
||||
GlobalKeyword = 146,
|
||||
BigIntKeyword = 147,
|
||||
OfKeyword = 148,
|
||||
QualifiedName = 149,
|
||||
ComputedPropertyName = 150,
|
||||
TypeParameter = 151,
|
||||
Parameter = 152,
|
||||
Decorator = 153,
|
||||
PropertySignature = 154,
|
||||
PropertyDeclaration = 155,
|
||||
MethodSignature = 156,
|
||||
MethodDeclaration = 157,
|
||||
Constructor = 158,
|
||||
GetAccessor = 159,
|
||||
SetAccessor = 160,
|
||||
CallSignature = 161,
|
||||
ConstructSignature = 162,
|
||||
IndexSignature = 163,
|
||||
TypePredicate = 164,
|
||||
TypeReference = 165,
|
||||
FunctionType = 166,
|
||||
ConstructorType = 167,
|
||||
TypeQuery = 168,
|
||||
TypeLiteral = 169,
|
||||
ArrayType = 170,
|
||||
TupleType = 171,
|
||||
OptionalType = 172,
|
||||
RestType = 173,
|
||||
UnionType = 174,
|
||||
IntersectionType = 175,
|
||||
ConditionalType = 176,
|
||||
InferType = 177,
|
||||
ParenthesizedType = 178,
|
||||
ThisType = 179,
|
||||
TypeOperator = 180,
|
||||
IndexedAccessType = 181,
|
||||
MappedType = 182,
|
||||
LiteralType = 183,
|
||||
ImportType = 184,
|
||||
ObjectBindingPattern = 185,
|
||||
ArrayBindingPattern = 186,
|
||||
BindingElement = 187,
|
||||
ArrayLiteralExpression = 188,
|
||||
ObjectLiteralExpression = 189,
|
||||
PropertyAccessExpression = 190,
|
||||
ElementAccessExpression = 191,
|
||||
CallExpression = 192,
|
||||
NewExpression = 193,
|
||||
TaggedTemplateExpression = 194,
|
||||
TypeAssertionExpression = 195,
|
||||
ParenthesizedExpression = 196,
|
||||
FunctionExpression = 197,
|
||||
ArrowFunction = 198,
|
||||
DeleteExpression = 199,
|
||||
TypeOfExpression = 200,
|
||||
VoidExpression = 201,
|
||||
AwaitExpression = 202,
|
||||
PrefixUnaryExpression = 203,
|
||||
PostfixUnaryExpression = 204,
|
||||
BinaryExpression = 205,
|
||||
ConditionalExpression = 206,
|
||||
TemplateExpression = 207,
|
||||
YieldExpression = 208,
|
||||
SpreadElement = 209,
|
||||
ClassExpression = 210,
|
||||
OmittedExpression = 211,
|
||||
ExpressionWithTypeArguments = 212,
|
||||
AsExpression = 213,
|
||||
NonNullExpression = 214,
|
||||
MetaProperty = 215,
|
||||
SyntheticExpression = 216,
|
||||
TemplateSpan = 217,
|
||||
SemicolonClassElement = 218,
|
||||
Block = 219,
|
||||
VariableStatement = 220,
|
||||
AssertsKeyword = 121,
|
||||
AnyKeyword = 122,
|
||||
AsyncKeyword = 123,
|
||||
AwaitKeyword = 124,
|
||||
BooleanKeyword = 125,
|
||||
ConstructorKeyword = 126,
|
||||
DeclareKeyword = 127,
|
||||
GetKeyword = 128,
|
||||
InferKeyword = 129,
|
||||
IsKeyword = 130,
|
||||
KeyOfKeyword = 131,
|
||||
ModuleKeyword = 132,
|
||||
NamespaceKeyword = 133,
|
||||
NeverKeyword = 134,
|
||||
ReadonlyKeyword = 135,
|
||||
RequireKeyword = 136,
|
||||
NumberKeyword = 137,
|
||||
ObjectKeyword = 138,
|
||||
SetKeyword = 139,
|
||||
StringKeyword = 140,
|
||||
SymbolKeyword = 141,
|
||||
TypeKeyword = 142,
|
||||
UndefinedKeyword = 143,
|
||||
UniqueKeyword = 144,
|
||||
UnknownKeyword = 145,
|
||||
FromKeyword = 146,
|
||||
GlobalKeyword = 147,
|
||||
BigIntKeyword = 148,
|
||||
OfKeyword = 149,
|
||||
QualifiedName = 150,
|
||||
ComputedPropertyName = 151,
|
||||
TypeParameter = 152,
|
||||
Parameter = 153,
|
||||
Decorator = 154,
|
||||
PropertySignature = 155,
|
||||
PropertyDeclaration = 156,
|
||||
MethodSignature = 157,
|
||||
MethodDeclaration = 158,
|
||||
Constructor = 159,
|
||||
GetAccessor = 160,
|
||||
SetAccessor = 161,
|
||||
CallSignature = 162,
|
||||
ConstructSignature = 163,
|
||||
IndexSignature = 164,
|
||||
TypePredicate = 165,
|
||||
TypeReference = 166,
|
||||
FunctionType = 167,
|
||||
ConstructorType = 168,
|
||||
TypeQuery = 169,
|
||||
TypeLiteral = 170,
|
||||
ArrayType = 171,
|
||||
TupleType = 172,
|
||||
OptionalType = 173,
|
||||
RestType = 174,
|
||||
UnionType = 175,
|
||||
IntersectionType = 176,
|
||||
ConditionalType = 177,
|
||||
InferType = 178,
|
||||
ParenthesizedType = 179,
|
||||
ThisType = 180,
|
||||
TypeOperator = 181,
|
||||
IndexedAccessType = 182,
|
||||
MappedType = 183,
|
||||
LiteralType = 184,
|
||||
ImportType = 185,
|
||||
ObjectBindingPattern = 186,
|
||||
ArrayBindingPattern = 187,
|
||||
BindingElement = 188,
|
||||
ArrayLiteralExpression = 189,
|
||||
ObjectLiteralExpression = 190,
|
||||
PropertyAccessExpression = 191,
|
||||
ElementAccessExpression = 192,
|
||||
CallExpression = 193,
|
||||
NewExpression = 194,
|
||||
TaggedTemplateExpression = 195,
|
||||
TypeAssertionExpression = 196,
|
||||
ParenthesizedExpression = 197,
|
||||
FunctionExpression = 198,
|
||||
ArrowFunction = 199,
|
||||
DeleteExpression = 200,
|
||||
TypeOfExpression = 201,
|
||||
VoidExpression = 202,
|
||||
AwaitExpression = 203,
|
||||
PrefixUnaryExpression = 204,
|
||||
PostfixUnaryExpression = 205,
|
||||
BinaryExpression = 206,
|
||||
ConditionalExpression = 207,
|
||||
TemplateExpression = 208,
|
||||
YieldExpression = 209,
|
||||
SpreadElement = 210,
|
||||
ClassExpression = 211,
|
||||
OmittedExpression = 212,
|
||||
ExpressionWithTypeArguments = 213,
|
||||
AsExpression = 214,
|
||||
NonNullExpression = 215,
|
||||
MetaProperty = 216,
|
||||
SyntheticExpression = 217,
|
||||
TemplateSpan = 218,
|
||||
SemicolonClassElement = 219,
|
||||
Block = 220,
|
||||
EmptyStatement = 221,
|
||||
ExpressionStatement = 222,
|
||||
IfStatement = 223,
|
||||
DoStatement = 224,
|
||||
WhileStatement = 225,
|
||||
ForStatement = 226,
|
||||
ForInStatement = 227,
|
||||
ForOfStatement = 228,
|
||||
ContinueStatement = 229,
|
||||
BreakStatement = 230,
|
||||
ReturnStatement = 231,
|
||||
WithStatement = 232,
|
||||
SwitchStatement = 233,
|
||||
LabeledStatement = 234,
|
||||
ThrowStatement = 235,
|
||||
TryStatement = 236,
|
||||
DebuggerStatement = 237,
|
||||
VariableDeclaration = 238,
|
||||
VariableDeclarationList = 239,
|
||||
FunctionDeclaration = 240,
|
||||
ClassDeclaration = 241,
|
||||
InterfaceDeclaration = 242,
|
||||
TypeAliasDeclaration = 243,
|
||||
EnumDeclaration = 244,
|
||||
ModuleDeclaration = 245,
|
||||
ModuleBlock = 246,
|
||||
CaseBlock = 247,
|
||||
NamespaceExportDeclaration = 248,
|
||||
ImportEqualsDeclaration = 249,
|
||||
ImportDeclaration = 250,
|
||||
ImportClause = 251,
|
||||
NamespaceImport = 252,
|
||||
NamedImports = 253,
|
||||
ImportSpecifier = 254,
|
||||
ExportAssignment = 255,
|
||||
ExportDeclaration = 256,
|
||||
NamedExports = 257,
|
||||
ExportSpecifier = 258,
|
||||
MissingDeclaration = 259,
|
||||
ExternalModuleReference = 260,
|
||||
JsxElement = 261,
|
||||
JsxSelfClosingElement = 262,
|
||||
JsxOpeningElement = 263,
|
||||
JsxClosingElement = 264,
|
||||
JsxFragment = 265,
|
||||
JsxOpeningFragment = 266,
|
||||
JsxClosingFragment = 267,
|
||||
JsxAttribute = 268,
|
||||
JsxAttributes = 269,
|
||||
JsxSpreadAttribute = 270,
|
||||
JsxExpression = 271,
|
||||
CaseClause = 272,
|
||||
DefaultClause = 273,
|
||||
HeritageClause = 274,
|
||||
CatchClause = 275,
|
||||
PropertyAssignment = 276,
|
||||
ShorthandPropertyAssignment = 277,
|
||||
SpreadAssignment = 278,
|
||||
EnumMember = 279,
|
||||
UnparsedPrologue = 280,
|
||||
UnparsedPrepend = 281,
|
||||
UnparsedText = 282,
|
||||
UnparsedInternalText = 283,
|
||||
UnparsedSyntheticReference = 284,
|
||||
SourceFile = 285,
|
||||
Bundle = 286,
|
||||
UnparsedSource = 287,
|
||||
InputFiles = 288,
|
||||
JSDocTypeExpression = 289,
|
||||
JSDocAllType = 290,
|
||||
JSDocUnknownType = 291,
|
||||
JSDocNullableType = 292,
|
||||
JSDocNonNullableType = 293,
|
||||
JSDocOptionalType = 294,
|
||||
JSDocFunctionType = 295,
|
||||
JSDocVariadicType = 296,
|
||||
JSDocNamepathType = 297,
|
||||
JSDocComment = 298,
|
||||
JSDocTypeLiteral = 299,
|
||||
JSDocSignature = 300,
|
||||
JSDocTag = 301,
|
||||
JSDocAugmentsTag = 302,
|
||||
JSDocAuthorTag = 303,
|
||||
JSDocClassTag = 304,
|
||||
JSDocCallbackTag = 305,
|
||||
JSDocEnumTag = 306,
|
||||
JSDocParameterTag = 307,
|
||||
JSDocReturnTag = 308,
|
||||
JSDocThisTag = 309,
|
||||
JSDocTypeTag = 310,
|
||||
JSDocTemplateTag = 311,
|
||||
JSDocTypedefTag = 312,
|
||||
JSDocPropertyTag = 313,
|
||||
SyntaxList = 314,
|
||||
NotEmittedStatement = 315,
|
||||
PartiallyEmittedExpression = 316,
|
||||
CommaListExpression = 317,
|
||||
MergeDeclarationMarker = 318,
|
||||
EndOfDeclarationMarker = 319,
|
||||
Count = 320,
|
||||
VariableStatement = 222,
|
||||
ExpressionStatement = 223,
|
||||
IfStatement = 224,
|
||||
DoStatement = 225,
|
||||
WhileStatement = 226,
|
||||
ForStatement = 227,
|
||||
ForInStatement = 228,
|
||||
ForOfStatement = 229,
|
||||
ContinueStatement = 230,
|
||||
BreakStatement = 231,
|
||||
ReturnStatement = 232,
|
||||
WithStatement = 233,
|
||||
SwitchStatement = 234,
|
||||
LabeledStatement = 235,
|
||||
ThrowStatement = 236,
|
||||
TryStatement = 237,
|
||||
DebuggerStatement = 238,
|
||||
VariableDeclaration = 239,
|
||||
VariableDeclarationList = 240,
|
||||
FunctionDeclaration = 241,
|
||||
ClassDeclaration = 242,
|
||||
InterfaceDeclaration = 243,
|
||||
TypeAliasDeclaration = 244,
|
||||
EnumDeclaration = 245,
|
||||
ModuleDeclaration = 246,
|
||||
ModuleBlock = 247,
|
||||
CaseBlock = 248,
|
||||
NamespaceExportDeclaration = 249,
|
||||
ImportEqualsDeclaration = 250,
|
||||
ImportDeclaration = 251,
|
||||
ImportClause = 252,
|
||||
NamespaceImport = 253,
|
||||
NamedImports = 254,
|
||||
ImportSpecifier = 255,
|
||||
ExportAssignment = 256,
|
||||
ExportDeclaration = 257,
|
||||
NamedExports = 258,
|
||||
ExportSpecifier = 259,
|
||||
MissingDeclaration = 260,
|
||||
ExternalModuleReference = 261,
|
||||
JsxElement = 262,
|
||||
JsxSelfClosingElement = 263,
|
||||
JsxOpeningElement = 264,
|
||||
JsxClosingElement = 265,
|
||||
JsxFragment = 266,
|
||||
JsxOpeningFragment = 267,
|
||||
JsxClosingFragment = 268,
|
||||
JsxAttribute = 269,
|
||||
JsxAttributes = 270,
|
||||
JsxSpreadAttribute = 271,
|
||||
JsxExpression = 272,
|
||||
CaseClause = 273,
|
||||
DefaultClause = 274,
|
||||
HeritageClause = 275,
|
||||
CatchClause = 276,
|
||||
PropertyAssignment = 277,
|
||||
ShorthandPropertyAssignment = 278,
|
||||
SpreadAssignment = 279,
|
||||
EnumMember = 280,
|
||||
UnparsedPrologue = 281,
|
||||
UnparsedPrepend = 282,
|
||||
UnparsedText = 283,
|
||||
UnparsedInternalText = 284,
|
||||
UnparsedSyntheticReference = 285,
|
||||
SourceFile = 286,
|
||||
Bundle = 287,
|
||||
UnparsedSource = 288,
|
||||
InputFiles = 289,
|
||||
JSDocTypeExpression = 290,
|
||||
JSDocAllType = 291,
|
||||
JSDocUnknownType = 292,
|
||||
JSDocNullableType = 293,
|
||||
JSDocNonNullableType = 294,
|
||||
JSDocOptionalType = 295,
|
||||
JSDocFunctionType = 296,
|
||||
JSDocVariadicType = 297,
|
||||
JSDocNamepathType = 298,
|
||||
JSDocComment = 299,
|
||||
JSDocTypeLiteral = 300,
|
||||
JSDocSignature = 301,
|
||||
JSDocTag = 302,
|
||||
JSDocAugmentsTag = 303,
|
||||
JSDocAuthorTag = 304,
|
||||
JSDocClassTag = 305,
|
||||
JSDocCallbackTag = 306,
|
||||
JSDocEnumTag = 307,
|
||||
JSDocParameterTag = 308,
|
||||
JSDocReturnTag = 309,
|
||||
JSDocThisTag = 310,
|
||||
JSDocTypeTag = 311,
|
||||
JSDocTemplateTag = 312,
|
||||
JSDocTypedefTag = 313,
|
||||
JSDocPropertyTag = 314,
|
||||
SyntaxList = 315,
|
||||
NotEmittedStatement = 316,
|
||||
PartiallyEmittedExpression = 317,
|
||||
CommaListExpression = 318,
|
||||
MergeDeclarationMarker = 319,
|
||||
EndOfDeclarationMarker = 320,
|
||||
Count = 321,
|
||||
FirstAssignment = 60,
|
||||
LastAssignment = 72,
|
||||
FirstCompoundAssignment = 61,
|
||||
@@ -405,15 +406,15 @@ declare namespace ts {
|
||||
FirstReservedWord = 74,
|
||||
LastReservedWord = 109,
|
||||
FirstKeyword = 74,
|
||||
LastKeyword = 148,
|
||||
LastKeyword = 149,
|
||||
FirstFutureReservedWord = 110,
|
||||
LastFutureReservedWord = 118,
|
||||
FirstTypeNode = 164,
|
||||
LastTypeNode = 184,
|
||||
FirstTypeNode = 165,
|
||||
LastTypeNode = 185,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 72,
|
||||
FirstToken = 0,
|
||||
LastToken = 148,
|
||||
LastToken = 149,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -422,11 +423,13 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 28,
|
||||
LastBinaryOperator = 72,
|
||||
FirstNode = 149,
|
||||
FirstJSDocNode = 289,
|
||||
LastJSDocNode = 313,
|
||||
FirstJSDocTagNode = 301,
|
||||
LastJSDocTagNode = 313,
|
||||
FirstStatement = 222,
|
||||
LastStatement = 238,
|
||||
FirstNode = 150,
|
||||
FirstJSDocNode = 290,
|
||||
LastJSDocNode = 314,
|
||||
FirstJSDocTagNode = 302,
|
||||
LastJSDocTagNode = 314,
|
||||
}
|
||||
export enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -517,6 +520,7 @@ declare namespace ts {
|
||||
export type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
export type PlusToken = Token<SyntaxKind.PlusToken>;
|
||||
export type MinusToken = Token<SyntaxKind.MinusToken>;
|
||||
export type AssertsToken = Token<SyntaxKind.AssertsKeyword>;
|
||||
export type Modifier = Token<SyntaxKind.AbstractKeyword> | Token<SyntaxKind.AsyncKeyword> | Token<SyntaxKind.ConstKeyword> | Token<SyntaxKind.DeclareKeyword> | Token<SyntaxKind.DefaultKeyword> | Token<SyntaxKind.ExportKeyword> | Token<SyntaxKind.PublicKeyword> | Token<SyntaxKind.PrivateKeyword> | Token<SyntaxKind.ProtectedKeyword> | Token<SyntaxKind.ReadonlyKeyword> | Token<SyntaxKind.StaticKeyword>;
|
||||
export type ModifiersArray = NodeArray<Modifier>;
|
||||
export interface Identifier extends PrimaryExpression, Declaration {
|
||||
@@ -770,8 +774,9 @@ declare namespace ts {
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
assertsModifier?: AssertsToken;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
type?: TypeNode;
|
||||
}
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeQuery;
|
||||
@@ -1669,13 +1674,19 @@ declare namespace ts {
|
||||
FalseCondition = 64,
|
||||
SwitchClause = 128,
|
||||
ArrayMutation = 256,
|
||||
Referenced = 512,
|
||||
Shared = 1024,
|
||||
PreFinally = 2048,
|
||||
AfterFinally = 4096,
|
||||
Call = 512,
|
||||
Referenced = 1024,
|
||||
Shared = 2048,
|
||||
PreFinally = 4096,
|
||||
AfterFinally = 8192,
|
||||
Label = 12,
|
||||
Condition = 96
|
||||
}
|
||||
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation;
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
export interface FlowLock {
|
||||
locked?: boolean;
|
||||
}
|
||||
@@ -1686,13 +1697,8 @@ declare namespace ts {
|
||||
antecedent: FlowNode;
|
||||
lock: FlowLock;
|
||||
}
|
||||
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
export interface FlowStart extends FlowNodeBase {
|
||||
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
node?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
}
|
||||
export interface FlowLabel extends FlowNodeBase {
|
||||
antecedents: FlowNode[] | undefined;
|
||||
@@ -1701,8 +1707,12 @@ declare namespace ts {
|
||||
node: Expression | VariableDeclaration | BindingElement;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowCall extends FlowNodeBase {
|
||||
node: CallExpression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowCondition extends FlowNodeBase {
|
||||
expression: Expression;
|
||||
node: Expression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowSwitchClause extends FlowNodeBase {
|
||||
@@ -2098,21 +2108,39 @@ declare namespace ts {
|
||||
}
|
||||
export enum TypePredicateKind {
|
||||
This = 0,
|
||||
Identifier = 1
|
||||
Identifier = 1,
|
||||
AssertsThis = 2,
|
||||
AssertsIdentifier = 3
|
||||
}
|
||||
export interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export interface ThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.This;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type;
|
||||
}
|
||||
export interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.Identifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
export interface AssertsThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsThis;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export interface AssertsIdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsIdentifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate;
|
||||
export enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -2340,7 +2368,7 @@ declare namespace ts {
|
||||
localTypeParameters: TypeParameter[] | undefined;
|
||||
thisType: TypeParameter | undefined;
|
||||
}
|
||||
export type BaseType = ObjectType | IntersectionType;
|
||||
export type BaseType = ObjectType | IntersectionType | TypeVariable;
|
||||
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[];
|
||||
declaredCallSignatures: Signature[];
|
||||
@@ -2539,6 +2567,7 @@ declare namespace ts {
|
||||
emitDeclarationOnly?: boolean;
|
||||
declarationDir?: string;
|
||||
disableSizeLimit?: boolean;
|
||||
disableSourceOfProjectReferenceRedirect?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
@@ -3845,7 +3874,9 @@ declare namespace ts {
|
||||
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
@@ -8499,7 +8530,6 @@ declare namespace ts.server {
|
||||
getGlobalProjectErrors(): readonly Diagnostic[];
|
||||
getAllProjectErrors(): readonly Diagnostic[];
|
||||
getLanguageService(ensureSynchronized?: boolean): LanguageService;
|
||||
private shouldEmitFile;
|
||||
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[];
|
||||
/**
|
||||
* Returns true if emit was conducted
|
||||
@@ -8580,11 +8610,25 @@ declare namespace ts.server {
|
||||
private typeAcquisition;
|
||||
private directoriesWatchedForWildcards;
|
||||
readonly canonicalConfigFilePath: NormalizedPath;
|
||||
private projectReferenceCallbacks;
|
||||
private mapOfDeclarationDirectories;
|
||||
/** Ref count to the project when opened from external project */
|
||||
private externalProjectRefCount;
|
||||
private projectErrors;
|
||||
private projectReferences;
|
||||
protected isInitialLoadPending: () => boolean;
|
||||
/**
|
||||
* This implementation of fileExists checks if the file being requested is
|
||||
* .d.ts file for the referenced Project.
|
||||
* If it is it returns true irrespective of whether that file exists on host
|
||||
*/
|
||||
fileExists(file: string): boolean;
|
||||
/**
|
||||
* This implementation of directoryExists checks if the directory being requested is
|
||||
* directory of .d.ts file for the referenced Project.
|
||||
* If it is it returns true irrespective of whether that directory exists on host
|
||||
*/
|
||||
directoryExists(path: string): boolean;
|
||||
/**
|
||||
* If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
|
||||
* @returns: true if set of files in the project stays the same and false - otherwise.
|
||||
|
||||
+256
-225
@@ -73,7 +73,7 @@ declare namespace ts {
|
||||
end: number;
|
||||
}
|
||||
export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword;
|
||||
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
|
||||
export enum SyntaxKind {
|
||||
Unknown = 0,
|
||||
@@ -198,206 +198,207 @@ declare namespace ts {
|
||||
YieldKeyword = 118,
|
||||
AbstractKeyword = 119,
|
||||
AsKeyword = 120,
|
||||
AnyKeyword = 121,
|
||||
AsyncKeyword = 122,
|
||||
AwaitKeyword = 123,
|
||||
BooleanKeyword = 124,
|
||||
ConstructorKeyword = 125,
|
||||
DeclareKeyword = 126,
|
||||
GetKeyword = 127,
|
||||
InferKeyword = 128,
|
||||
IsKeyword = 129,
|
||||
KeyOfKeyword = 130,
|
||||
ModuleKeyword = 131,
|
||||
NamespaceKeyword = 132,
|
||||
NeverKeyword = 133,
|
||||
ReadonlyKeyword = 134,
|
||||
RequireKeyword = 135,
|
||||
NumberKeyword = 136,
|
||||
ObjectKeyword = 137,
|
||||
SetKeyword = 138,
|
||||
StringKeyword = 139,
|
||||
SymbolKeyword = 140,
|
||||
TypeKeyword = 141,
|
||||
UndefinedKeyword = 142,
|
||||
UniqueKeyword = 143,
|
||||
UnknownKeyword = 144,
|
||||
FromKeyword = 145,
|
||||
GlobalKeyword = 146,
|
||||
BigIntKeyword = 147,
|
||||
OfKeyword = 148,
|
||||
QualifiedName = 149,
|
||||
ComputedPropertyName = 150,
|
||||
TypeParameter = 151,
|
||||
Parameter = 152,
|
||||
Decorator = 153,
|
||||
PropertySignature = 154,
|
||||
PropertyDeclaration = 155,
|
||||
MethodSignature = 156,
|
||||
MethodDeclaration = 157,
|
||||
Constructor = 158,
|
||||
GetAccessor = 159,
|
||||
SetAccessor = 160,
|
||||
CallSignature = 161,
|
||||
ConstructSignature = 162,
|
||||
IndexSignature = 163,
|
||||
TypePredicate = 164,
|
||||
TypeReference = 165,
|
||||
FunctionType = 166,
|
||||
ConstructorType = 167,
|
||||
TypeQuery = 168,
|
||||
TypeLiteral = 169,
|
||||
ArrayType = 170,
|
||||
TupleType = 171,
|
||||
OptionalType = 172,
|
||||
RestType = 173,
|
||||
UnionType = 174,
|
||||
IntersectionType = 175,
|
||||
ConditionalType = 176,
|
||||
InferType = 177,
|
||||
ParenthesizedType = 178,
|
||||
ThisType = 179,
|
||||
TypeOperator = 180,
|
||||
IndexedAccessType = 181,
|
||||
MappedType = 182,
|
||||
LiteralType = 183,
|
||||
ImportType = 184,
|
||||
ObjectBindingPattern = 185,
|
||||
ArrayBindingPattern = 186,
|
||||
BindingElement = 187,
|
||||
ArrayLiteralExpression = 188,
|
||||
ObjectLiteralExpression = 189,
|
||||
PropertyAccessExpression = 190,
|
||||
ElementAccessExpression = 191,
|
||||
CallExpression = 192,
|
||||
NewExpression = 193,
|
||||
TaggedTemplateExpression = 194,
|
||||
TypeAssertionExpression = 195,
|
||||
ParenthesizedExpression = 196,
|
||||
FunctionExpression = 197,
|
||||
ArrowFunction = 198,
|
||||
DeleteExpression = 199,
|
||||
TypeOfExpression = 200,
|
||||
VoidExpression = 201,
|
||||
AwaitExpression = 202,
|
||||
PrefixUnaryExpression = 203,
|
||||
PostfixUnaryExpression = 204,
|
||||
BinaryExpression = 205,
|
||||
ConditionalExpression = 206,
|
||||
TemplateExpression = 207,
|
||||
YieldExpression = 208,
|
||||
SpreadElement = 209,
|
||||
ClassExpression = 210,
|
||||
OmittedExpression = 211,
|
||||
ExpressionWithTypeArguments = 212,
|
||||
AsExpression = 213,
|
||||
NonNullExpression = 214,
|
||||
MetaProperty = 215,
|
||||
SyntheticExpression = 216,
|
||||
TemplateSpan = 217,
|
||||
SemicolonClassElement = 218,
|
||||
Block = 219,
|
||||
VariableStatement = 220,
|
||||
AssertsKeyword = 121,
|
||||
AnyKeyword = 122,
|
||||
AsyncKeyword = 123,
|
||||
AwaitKeyword = 124,
|
||||
BooleanKeyword = 125,
|
||||
ConstructorKeyword = 126,
|
||||
DeclareKeyword = 127,
|
||||
GetKeyword = 128,
|
||||
InferKeyword = 129,
|
||||
IsKeyword = 130,
|
||||
KeyOfKeyword = 131,
|
||||
ModuleKeyword = 132,
|
||||
NamespaceKeyword = 133,
|
||||
NeverKeyword = 134,
|
||||
ReadonlyKeyword = 135,
|
||||
RequireKeyword = 136,
|
||||
NumberKeyword = 137,
|
||||
ObjectKeyword = 138,
|
||||
SetKeyword = 139,
|
||||
StringKeyword = 140,
|
||||
SymbolKeyword = 141,
|
||||
TypeKeyword = 142,
|
||||
UndefinedKeyword = 143,
|
||||
UniqueKeyword = 144,
|
||||
UnknownKeyword = 145,
|
||||
FromKeyword = 146,
|
||||
GlobalKeyword = 147,
|
||||
BigIntKeyword = 148,
|
||||
OfKeyword = 149,
|
||||
QualifiedName = 150,
|
||||
ComputedPropertyName = 151,
|
||||
TypeParameter = 152,
|
||||
Parameter = 153,
|
||||
Decorator = 154,
|
||||
PropertySignature = 155,
|
||||
PropertyDeclaration = 156,
|
||||
MethodSignature = 157,
|
||||
MethodDeclaration = 158,
|
||||
Constructor = 159,
|
||||
GetAccessor = 160,
|
||||
SetAccessor = 161,
|
||||
CallSignature = 162,
|
||||
ConstructSignature = 163,
|
||||
IndexSignature = 164,
|
||||
TypePredicate = 165,
|
||||
TypeReference = 166,
|
||||
FunctionType = 167,
|
||||
ConstructorType = 168,
|
||||
TypeQuery = 169,
|
||||
TypeLiteral = 170,
|
||||
ArrayType = 171,
|
||||
TupleType = 172,
|
||||
OptionalType = 173,
|
||||
RestType = 174,
|
||||
UnionType = 175,
|
||||
IntersectionType = 176,
|
||||
ConditionalType = 177,
|
||||
InferType = 178,
|
||||
ParenthesizedType = 179,
|
||||
ThisType = 180,
|
||||
TypeOperator = 181,
|
||||
IndexedAccessType = 182,
|
||||
MappedType = 183,
|
||||
LiteralType = 184,
|
||||
ImportType = 185,
|
||||
ObjectBindingPattern = 186,
|
||||
ArrayBindingPattern = 187,
|
||||
BindingElement = 188,
|
||||
ArrayLiteralExpression = 189,
|
||||
ObjectLiteralExpression = 190,
|
||||
PropertyAccessExpression = 191,
|
||||
ElementAccessExpression = 192,
|
||||
CallExpression = 193,
|
||||
NewExpression = 194,
|
||||
TaggedTemplateExpression = 195,
|
||||
TypeAssertionExpression = 196,
|
||||
ParenthesizedExpression = 197,
|
||||
FunctionExpression = 198,
|
||||
ArrowFunction = 199,
|
||||
DeleteExpression = 200,
|
||||
TypeOfExpression = 201,
|
||||
VoidExpression = 202,
|
||||
AwaitExpression = 203,
|
||||
PrefixUnaryExpression = 204,
|
||||
PostfixUnaryExpression = 205,
|
||||
BinaryExpression = 206,
|
||||
ConditionalExpression = 207,
|
||||
TemplateExpression = 208,
|
||||
YieldExpression = 209,
|
||||
SpreadElement = 210,
|
||||
ClassExpression = 211,
|
||||
OmittedExpression = 212,
|
||||
ExpressionWithTypeArguments = 213,
|
||||
AsExpression = 214,
|
||||
NonNullExpression = 215,
|
||||
MetaProperty = 216,
|
||||
SyntheticExpression = 217,
|
||||
TemplateSpan = 218,
|
||||
SemicolonClassElement = 219,
|
||||
Block = 220,
|
||||
EmptyStatement = 221,
|
||||
ExpressionStatement = 222,
|
||||
IfStatement = 223,
|
||||
DoStatement = 224,
|
||||
WhileStatement = 225,
|
||||
ForStatement = 226,
|
||||
ForInStatement = 227,
|
||||
ForOfStatement = 228,
|
||||
ContinueStatement = 229,
|
||||
BreakStatement = 230,
|
||||
ReturnStatement = 231,
|
||||
WithStatement = 232,
|
||||
SwitchStatement = 233,
|
||||
LabeledStatement = 234,
|
||||
ThrowStatement = 235,
|
||||
TryStatement = 236,
|
||||
DebuggerStatement = 237,
|
||||
VariableDeclaration = 238,
|
||||
VariableDeclarationList = 239,
|
||||
FunctionDeclaration = 240,
|
||||
ClassDeclaration = 241,
|
||||
InterfaceDeclaration = 242,
|
||||
TypeAliasDeclaration = 243,
|
||||
EnumDeclaration = 244,
|
||||
ModuleDeclaration = 245,
|
||||
ModuleBlock = 246,
|
||||
CaseBlock = 247,
|
||||
NamespaceExportDeclaration = 248,
|
||||
ImportEqualsDeclaration = 249,
|
||||
ImportDeclaration = 250,
|
||||
ImportClause = 251,
|
||||
NamespaceImport = 252,
|
||||
NamedImports = 253,
|
||||
ImportSpecifier = 254,
|
||||
ExportAssignment = 255,
|
||||
ExportDeclaration = 256,
|
||||
NamedExports = 257,
|
||||
ExportSpecifier = 258,
|
||||
MissingDeclaration = 259,
|
||||
ExternalModuleReference = 260,
|
||||
JsxElement = 261,
|
||||
JsxSelfClosingElement = 262,
|
||||
JsxOpeningElement = 263,
|
||||
JsxClosingElement = 264,
|
||||
JsxFragment = 265,
|
||||
JsxOpeningFragment = 266,
|
||||
JsxClosingFragment = 267,
|
||||
JsxAttribute = 268,
|
||||
JsxAttributes = 269,
|
||||
JsxSpreadAttribute = 270,
|
||||
JsxExpression = 271,
|
||||
CaseClause = 272,
|
||||
DefaultClause = 273,
|
||||
HeritageClause = 274,
|
||||
CatchClause = 275,
|
||||
PropertyAssignment = 276,
|
||||
ShorthandPropertyAssignment = 277,
|
||||
SpreadAssignment = 278,
|
||||
EnumMember = 279,
|
||||
UnparsedPrologue = 280,
|
||||
UnparsedPrepend = 281,
|
||||
UnparsedText = 282,
|
||||
UnparsedInternalText = 283,
|
||||
UnparsedSyntheticReference = 284,
|
||||
SourceFile = 285,
|
||||
Bundle = 286,
|
||||
UnparsedSource = 287,
|
||||
InputFiles = 288,
|
||||
JSDocTypeExpression = 289,
|
||||
JSDocAllType = 290,
|
||||
JSDocUnknownType = 291,
|
||||
JSDocNullableType = 292,
|
||||
JSDocNonNullableType = 293,
|
||||
JSDocOptionalType = 294,
|
||||
JSDocFunctionType = 295,
|
||||
JSDocVariadicType = 296,
|
||||
JSDocNamepathType = 297,
|
||||
JSDocComment = 298,
|
||||
JSDocTypeLiteral = 299,
|
||||
JSDocSignature = 300,
|
||||
JSDocTag = 301,
|
||||
JSDocAugmentsTag = 302,
|
||||
JSDocAuthorTag = 303,
|
||||
JSDocClassTag = 304,
|
||||
JSDocCallbackTag = 305,
|
||||
JSDocEnumTag = 306,
|
||||
JSDocParameterTag = 307,
|
||||
JSDocReturnTag = 308,
|
||||
JSDocThisTag = 309,
|
||||
JSDocTypeTag = 310,
|
||||
JSDocTemplateTag = 311,
|
||||
JSDocTypedefTag = 312,
|
||||
JSDocPropertyTag = 313,
|
||||
SyntaxList = 314,
|
||||
NotEmittedStatement = 315,
|
||||
PartiallyEmittedExpression = 316,
|
||||
CommaListExpression = 317,
|
||||
MergeDeclarationMarker = 318,
|
||||
EndOfDeclarationMarker = 319,
|
||||
Count = 320,
|
||||
VariableStatement = 222,
|
||||
ExpressionStatement = 223,
|
||||
IfStatement = 224,
|
||||
DoStatement = 225,
|
||||
WhileStatement = 226,
|
||||
ForStatement = 227,
|
||||
ForInStatement = 228,
|
||||
ForOfStatement = 229,
|
||||
ContinueStatement = 230,
|
||||
BreakStatement = 231,
|
||||
ReturnStatement = 232,
|
||||
WithStatement = 233,
|
||||
SwitchStatement = 234,
|
||||
LabeledStatement = 235,
|
||||
ThrowStatement = 236,
|
||||
TryStatement = 237,
|
||||
DebuggerStatement = 238,
|
||||
VariableDeclaration = 239,
|
||||
VariableDeclarationList = 240,
|
||||
FunctionDeclaration = 241,
|
||||
ClassDeclaration = 242,
|
||||
InterfaceDeclaration = 243,
|
||||
TypeAliasDeclaration = 244,
|
||||
EnumDeclaration = 245,
|
||||
ModuleDeclaration = 246,
|
||||
ModuleBlock = 247,
|
||||
CaseBlock = 248,
|
||||
NamespaceExportDeclaration = 249,
|
||||
ImportEqualsDeclaration = 250,
|
||||
ImportDeclaration = 251,
|
||||
ImportClause = 252,
|
||||
NamespaceImport = 253,
|
||||
NamedImports = 254,
|
||||
ImportSpecifier = 255,
|
||||
ExportAssignment = 256,
|
||||
ExportDeclaration = 257,
|
||||
NamedExports = 258,
|
||||
ExportSpecifier = 259,
|
||||
MissingDeclaration = 260,
|
||||
ExternalModuleReference = 261,
|
||||
JsxElement = 262,
|
||||
JsxSelfClosingElement = 263,
|
||||
JsxOpeningElement = 264,
|
||||
JsxClosingElement = 265,
|
||||
JsxFragment = 266,
|
||||
JsxOpeningFragment = 267,
|
||||
JsxClosingFragment = 268,
|
||||
JsxAttribute = 269,
|
||||
JsxAttributes = 270,
|
||||
JsxSpreadAttribute = 271,
|
||||
JsxExpression = 272,
|
||||
CaseClause = 273,
|
||||
DefaultClause = 274,
|
||||
HeritageClause = 275,
|
||||
CatchClause = 276,
|
||||
PropertyAssignment = 277,
|
||||
ShorthandPropertyAssignment = 278,
|
||||
SpreadAssignment = 279,
|
||||
EnumMember = 280,
|
||||
UnparsedPrologue = 281,
|
||||
UnparsedPrepend = 282,
|
||||
UnparsedText = 283,
|
||||
UnparsedInternalText = 284,
|
||||
UnparsedSyntheticReference = 285,
|
||||
SourceFile = 286,
|
||||
Bundle = 287,
|
||||
UnparsedSource = 288,
|
||||
InputFiles = 289,
|
||||
JSDocTypeExpression = 290,
|
||||
JSDocAllType = 291,
|
||||
JSDocUnknownType = 292,
|
||||
JSDocNullableType = 293,
|
||||
JSDocNonNullableType = 294,
|
||||
JSDocOptionalType = 295,
|
||||
JSDocFunctionType = 296,
|
||||
JSDocVariadicType = 297,
|
||||
JSDocNamepathType = 298,
|
||||
JSDocComment = 299,
|
||||
JSDocTypeLiteral = 300,
|
||||
JSDocSignature = 301,
|
||||
JSDocTag = 302,
|
||||
JSDocAugmentsTag = 303,
|
||||
JSDocAuthorTag = 304,
|
||||
JSDocClassTag = 305,
|
||||
JSDocCallbackTag = 306,
|
||||
JSDocEnumTag = 307,
|
||||
JSDocParameterTag = 308,
|
||||
JSDocReturnTag = 309,
|
||||
JSDocThisTag = 310,
|
||||
JSDocTypeTag = 311,
|
||||
JSDocTemplateTag = 312,
|
||||
JSDocTypedefTag = 313,
|
||||
JSDocPropertyTag = 314,
|
||||
SyntaxList = 315,
|
||||
NotEmittedStatement = 316,
|
||||
PartiallyEmittedExpression = 317,
|
||||
CommaListExpression = 318,
|
||||
MergeDeclarationMarker = 319,
|
||||
EndOfDeclarationMarker = 320,
|
||||
Count = 321,
|
||||
FirstAssignment = 60,
|
||||
LastAssignment = 72,
|
||||
FirstCompoundAssignment = 61,
|
||||
@@ -405,15 +406,15 @@ declare namespace ts {
|
||||
FirstReservedWord = 74,
|
||||
LastReservedWord = 109,
|
||||
FirstKeyword = 74,
|
||||
LastKeyword = 148,
|
||||
LastKeyword = 149,
|
||||
FirstFutureReservedWord = 110,
|
||||
LastFutureReservedWord = 118,
|
||||
FirstTypeNode = 164,
|
||||
LastTypeNode = 184,
|
||||
FirstTypeNode = 165,
|
||||
LastTypeNode = 185,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 72,
|
||||
FirstToken = 0,
|
||||
LastToken = 148,
|
||||
LastToken = 149,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -422,11 +423,13 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 28,
|
||||
LastBinaryOperator = 72,
|
||||
FirstNode = 149,
|
||||
FirstJSDocNode = 289,
|
||||
LastJSDocNode = 313,
|
||||
FirstJSDocTagNode = 301,
|
||||
LastJSDocTagNode = 313,
|
||||
FirstStatement = 222,
|
||||
LastStatement = 238,
|
||||
FirstNode = 150,
|
||||
FirstJSDocNode = 290,
|
||||
LastJSDocNode = 314,
|
||||
FirstJSDocTagNode = 302,
|
||||
LastJSDocTagNode = 314,
|
||||
}
|
||||
export enum NodeFlags {
|
||||
None = 0,
|
||||
@@ -517,6 +520,7 @@ declare namespace ts {
|
||||
export type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>;
|
||||
export type PlusToken = Token<SyntaxKind.PlusToken>;
|
||||
export type MinusToken = Token<SyntaxKind.MinusToken>;
|
||||
export type AssertsToken = Token<SyntaxKind.AssertsKeyword>;
|
||||
export type Modifier = Token<SyntaxKind.AbstractKeyword> | Token<SyntaxKind.AsyncKeyword> | Token<SyntaxKind.ConstKeyword> | Token<SyntaxKind.DeclareKeyword> | Token<SyntaxKind.DefaultKeyword> | Token<SyntaxKind.ExportKeyword> | Token<SyntaxKind.PublicKeyword> | Token<SyntaxKind.PrivateKeyword> | Token<SyntaxKind.ProtectedKeyword> | Token<SyntaxKind.ReadonlyKeyword> | Token<SyntaxKind.StaticKeyword>;
|
||||
export type ModifiersArray = NodeArray<Modifier>;
|
||||
export interface Identifier extends PrimaryExpression, Declaration {
|
||||
@@ -770,8 +774,9 @@ declare namespace ts {
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
kind: SyntaxKind.TypePredicate;
|
||||
parent: SignatureDeclaration | JSDocTypeExpression;
|
||||
assertsModifier?: AssertsToken;
|
||||
parameterName: Identifier | ThisTypeNode;
|
||||
type: TypeNode;
|
||||
type?: TypeNode;
|
||||
}
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeQuery;
|
||||
@@ -1669,13 +1674,19 @@ declare namespace ts {
|
||||
FalseCondition = 64,
|
||||
SwitchClause = 128,
|
||||
ArrayMutation = 256,
|
||||
Referenced = 512,
|
||||
Shared = 1024,
|
||||
PreFinally = 2048,
|
||||
AfterFinally = 4096,
|
||||
Call = 512,
|
||||
Referenced = 1024,
|
||||
Shared = 2048,
|
||||
PreFinally = 4096,
|
||||
AfterFinally = 8192,
|
||||
Label = 12,
|
||||
Condition = 96
|
||||
}
|
||||
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation;
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
export interface FlowLock {
|
||||
locked?: boolean;
|
||||
}
|
||||
@@ -1686,13 +1697,8 @@ declare namespace ts {
|
||||
antecedent: FlowNode;
|
||||
lock: FlowLock;
|
||||
}
|
||||
export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation;
|
||||
export interface FlowNodeBase {
|
||||
flags: FlowFlags;
|
||||
id?: number;
|
||||
}
|
||||
export interface FlowStart extends FlowNodeBase {
|
||||
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
node?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
}
|
||||
export interface FlowLabel extends FlowNodeBase {
|
||||
antecedents: FlowNode[] | undefined;
|
||||
@@ -1701,8 +1707,12 @@ declare namespace ts {
|
||||
node: Expression | VariableDeclaration | BindingElement;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowCall extends FlowNodeBase {
|
||||
node: CallExpression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowCondition extends FlowNodeBase {
|
||||
expression: Expression;
|
||||
node: Expression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
export interface FlowSwitchClause extends FlowNodeBase {
|
||||
@@ -2098,21 +2108,39 @@ declare namespace ts {
|
||||
}
|
||||
export enum TypePredicateKind {
|
||||
This = 0,
|
||||
Identifier = 1
|
||||
Identifier = 1,
|
||||
AssertsThis = 2,
|
||||
AssertsIdentifier = 3
|
||||
}
|
||||
export interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export interface ThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.This;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type;
|
||||
}
|
||||
export interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.Identifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
export interface AssertsThisTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsThis;
|
||||
parameterName: undefined;
|
||||
parameterIndex: undefined;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export interface AssertsIdentifierTypePredicate extends TypePredicateBase {
|
||||
kind: TypePredicateKind.AssertsIdentifier;
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type | undefined;
|
||||
}
|
||||
export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate;
|
||||
export enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -2340,7 +2368,7 @@ declare namespace ts {
|
||||
localTypeParameters: TypeParameter[] | undefined;
|
||||
thisType: TypeParameter | undefined;
|
||||
}
|
||||
export type BaseType = ObjectType | IntersectionType;
|
||||
export type BaseType = ObjectType | IntersectionType | TypeVariable;
|
||||
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[];
|
||||
declaredCallSignatures: Signature[];
|
||||
@@ -2539,6 +2567,7 @@ declare namespace ts {
|
||||
emitDeclarationOnly?: boolean;
|
||||
declarationDir?: string;
|
||||
disableSizeLimit?: boolean;
|
||||
disableSourceOfProjectReferenceRedirect?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
@@ -3845,7 +3874,9 @@ declare namespace ts {
|
||||
function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode;
|
||||
function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode;
|
||||
function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode;
|
||||
function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode;
|
||||
function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode;
|
||||
function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode;
|
||||
function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode;
|
||||
function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode;
|
||||
|
||||
@@ -8,10 +8,9 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2739: Type '(number[] | string[])[]' is missing the following properties from type 'tup': 0, 1
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2739: Type 'number[]' is missing the following properties from type '[number, number, number]': 0, 1, 2
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => Number'.
|
||||
Type 'string | number' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
The types returned by 'pop()' are incompatible between these types.
|
||||
Type 'string | number' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (8 errors) ====
|
||||
@@ -67,8 +66,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
|
||||
~~
|
||||
!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number' is not assignable to type '() => Number'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: The types returned by 'pop()' are incompatible between these types.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
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 '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[]'.
|
||||
Type 'A' is not assignable to type 'B'.
|
||||
The types returned by 'concat(...)' are incompatible between these types.
|
||||
Type 'A[]' is not assignable to type 'B[]'.
|
||||
Type 'A' is not assignable to type 'B'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ====
|
||||
@@ -32,8 +31,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
|
||||
rrb = cra; // error: 'A' is not assignable to '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[]'.
|
||||
!!! error TS2322: Type 'A' is not assignable to type 'B'.
|
||||
!!! error TS2322: The types returned by 'concat(...)' are incompatible between these types.
|
||||
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.
|
||||
!!! error TS2322: Type 'A' is not assignable to type 'B'.
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(116,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(117,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(118,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(121,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(122,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(123,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(124,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
|
||||
|
||||
==== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts (7 errors) ====
|
||||
declare function isString(value: unknown): value is string;
|
||||
declare function isArrayOfStrings(value: unknown): value is string[];
|
||||
|
||||
const assert: (value: unknown) => asserts value = value => {}
|
||||
|
||||
declare function assertIsString(value: unknown): asserts value is string;
|
||||
declare function assertIsArrayOfStrings(value: unknown): asserts value is string[];
|
||||
declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
|
||||
function f01(x: unknown) {
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x instanceof Error);
|
||||
x.message;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(typeof x === "boolean" || typeof x === "number");
|
||||
x.toLocaleString;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(isArrayOfStrings(x));
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
assertDefined(x);
|
||||
x; // string
|
||||
}
|
||||
}
|
||||
|
||||
function f02(x: string | undefined) {
|
||||
if (!!true) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
|
||||
function f03(x: string | undefined, assert: (value: unknown) => asserts value) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
|
||||
namespace Debug {
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
export declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
}
|
||||
|
||||
function f10(x: string | undefined) {
|
||||
if (!!true) {
|
||||
Debug.assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
assert(value: unknown): asserts value {
|
||||
if (value) return;
|
||||
throw new Error();
|
||||
}
|
||||
isTest2(): this is Test2 {
|
||||
return this instanceof Test2;
|
||||
}
|
||||
assertIsTest2(): asserts this is Test2 {
|
||||
if (this instanceof Test2) return;
|
||||
throw new Error();
|
||||
}
|
||||
assertThis(): asserts this {
|
||||
if (!this) return;
|
||||
throw new Error();
|
||||
}
|
||||
bar() {
|
||||
this.assertThis();
|
||||
this;
|
||||
}
|
||||
foo(x: unknown) {
|
||||
this.assert(typeof x === "string");
|
||||
x.length;
|
||||
if (this.isTest2()) {
|
||||
this.z;
|
||||
}
|
||||
this.assertIsTest2();
|
||||
this.z;
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Test {
|
||||
z = 0;
|
||||
}
|
||||
|
||||
// Invalid constructs
|
||||
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
|
||||
declare class Wat {
|
||||
get p1(): this is string;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
set p1(x: this is string);
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
get p2(): asserts this is string;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
set p2(x: asserts this is string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
//// [assertionTypePredicates1.ts]
|
||||
declare function isString(value: unknown): value is string;
|
||||
declare function isArrayOfStrings(value: unknown): value is string[];
|
||||
|
||||
const assert: (value: unknown) => asserts value = value => {}
|
||||
|
||||
declare function assertIsString(value: unknown): asserts value is string;
|
||||
declare function assertIsArrayOfStrings(value: unknown): asserts value is string[];
|
||||
declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
|
||||
function f01(x: unknown) {
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x instanceof Error);
|
||||
x.message;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(typeof x === "boolean" || typeof x === "number");
|
||||
x.toLocaleString;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(isArrayOfStrings(x));
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
assertDefined(x);
|
||||
x; // string
|
||||
}
|
||||
}
|
||||
|
||||
function f02(x: string | undefined) {
|
||||
if (!!true) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
|
||||
function f03(x: string | undefined, assert: (value: unknown) => asserts value) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
|
||||
namespace Debug {
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
export declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
}
|
||||
|
||||
function f10(x: string | undefined) {
|
||||
if (!!true) {
|
||||
Debug.assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
assert(value: unknown): asserts value {
|
||||
if (value) return;
|
||||
throw new Error();
|
||||
}
|
||||
isTest2(): this is Test2 {
|
||||
return this instanceof Test2;
|
||||
}
|
||||
assertIsTest2(): asserts this is Test2 {
|
||||
if (this instanceof Test2) return;
|
||||
throw new Error();
|
||||
}
|
||||
assertThis(): asserts this {
|
||||
if (!this) return;
|
||||
throw new Error();
|
||||
}
|
||||
bar() {
|
||||
this.assertThis();
|
||||
this;
|
||||
}
|
||||
foo(x: unknown) {
|
||||
this.assert(typeof x === "string");
|
||||
x.length;
|
||||
if (this.isTest2()) {
|
||||
this.z;
|
||||
}
|
||||
this.assertIsTest2();
|
||||
this.z;
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Test {
|
||||
z = 0;
|
||||
}
|
||||
|
||||
// Invalid constructs
|
||||
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
|
||||
declare class Wat {
|
||||
get p1(): this is string;
|
||||
set p1(x: this is string);
|
||||
get p2(): asserts this is string;
|
||||
set p2(x: asserts this is string);
|
||||
}
|
||||
|
||||
|
||||
//// [assertionTypePredicates1.js]
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var assert = function (value) { };
|
||||
function f01(x) {
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x instanceof Error);
|
||||
x.message;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(typeof x === "boolean" || typeof x === "number");
|
||||
x.toLocaleString;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(isArrayOfStrings(x));
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
assertDefined(x);
|
||||
x; // string
|
||||
}
|
||||
}
|
||||
function f02(x) {
|
||||
if (!!true) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
function f03(x, assert) {
|
||||
assert(x);
|
||||
x.length;
|
||||
}
|
||||
var Debug;
|
||||
(function (Debug) {
|
||||
})(Debug || (Debug = {}));
|
||||
function f10(x) {
|
||||
if (!!true) {
|
||||
Debug.assert(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(x !== undefined);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assertDefined(x);
|
||||
x.length;
|
||||
}
|
||||
}
|
||||
var Test = /** @class */ (function () {
|
||||
function Test() {
|
||||
}
|
||||
Test.prototype.assert = function (value) {
|
||||
if (value)
|
||||
return;
|
||||
throw new Error();
|
||||
};
|
||||
Test.prototype.isTest2 = function () {
|
||||
return this instanceof Test2;
|
||||
};
|
||||
Test.prototype.assertIsTest2 = function () {
|
||||
if (this instanceof Test2)
|
||||
return;
|
||||
throw new Error();
|
||||
};
|
||||
Test.prototype.assertThis = function () {
|
||||
if (!this)
|
||||
return;
|
||||
throw new Error();
|
||||
};
|
||||
Test.prototype.bar = function () {
|
||||
this.assertThis();
|
||||
this;
|
||||
};
|
||||
Test.prototype.foo = function (x) {
|
||||
this.assert(typeof x === "string");
|
||||
x.length;
|
||||
if (this.isTest2()) {
|
||||
this.z;
|
||||
}
|
||||
this.assertIsTest2();
|
||||
this.z;
|
||||
};
|
||||
return Test;
|
||||
}());
|
||||
var Test2 = /** @class */ (function (_super) {
|
||||
__extends(Test2, _super);
|
||||
function Test2() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.z = 0;
|
||||
return _this;
|
||||
}
|
||||
return Test2;
|
||||
}(Test));
|
||||
|
||||
|
||||
//// [assertionTypePredicates1.d.ts]
|
||||
declare function isString(value: unknown): value is string;
|
||||
declare function isArrayOfStrings(value: unknown): value is string[];
|
||||
declare const assert: (value: unknown) => asserts value;
|
||||
declare function assertIsString(value: unknown): asserts value is string;
|
||||
declare function assertIsArrayOfStrings(value: unknown): asserts value is string[];
|
||||
declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
declare function f01(x: unknown): void;
|
||||
declare function f02(x: string | undefined): void;
|
||||
declare function f03(x: string | undefined, assert: (value: unknown) => asserts value): void;
|
||||
declare namespace Debug {
|
||||
function assert(value: unknown, message?: string): asserts value;
|
||||
function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
}
|
||||
declare function f10(x: string | undefined): void;
|
||||
declare class Test {
|
||||
assert(value: unknown): asserts value;
|
||||
isTest2(): this is Test2;
|
||||
assertIsTest2(): asserts this is Test2;
|
||||
assertThis(): asserts this;
|
||||
bar(): void;
|
||||
foo(x: unknown): void;
|
||||
}
|
||||
declare class Test2 extends Test {
|
||||
z: number;
|
||||
}
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
declare class Wat {
|
||||
get p1(): this is string;
|
||||
set p1(x: this is string);
|
||||
get p2(): asserts this is string;
|
||||
set p2(x: asserts this is string);
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
=== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts ===
|
||||
declare function isString(value: unknown): value is string;
|
||||
>isString : Symbol(isString, Decl(assertionTypePredicates1.ts, 0, 0))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 0, 26))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 0, 26))
|
||||
|
||||
declare function isArrayOfStrings(value: unknown): value is string[];
|
||||
>isArrayOfStrings : Symbol(isArrayOfStrings, Decl(assertionTypePredicates1.ts, 0, 59))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 1, 34))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 1, 34))
|
||||
|
||||
const assert: (value: unknown) => asserts value = value => {}
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 15))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 15))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 3, 49))
|
||||
|
||||
declare function assertIsString(value: unknown): asserts value is string;
|
||||
>assertIsString : Symbol(assertIsString, Decl(assertionTypePredicates1.ts, 3, 61))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 5, 32))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 5, 32))
|
||||
|
||||
declare function assertIsArrayOfStrings(value: unknown): asserts value is string[];
|
||||
>assertIsArrayOfStrings : Symbol(assertIsArrayOfStrings, Decl(assertionTypePredicates1.ts, 5, 73))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 6, 40))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 6, 40))
|
||||
|
||||
declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 7, 34))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 7, 34))
|
||||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 7, 31))
|
||||
|
||||
function f01(x: unknown) {
|
||||
>f01 : Symbol(f01, Decl(assertionTypePredicates1.ts, 7, 77))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x instanceof Error);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
x.message;
|
||||
>x.message : Symbol(Error.message, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>message : Symbol(Error.message, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(typeof x === "boolean" || typeof x === "number");
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x.toLocaleString;
|
||||
>x.toLocaleString : Symbol(toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>toLocaleString : Symbol(toLocaleString, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(isArrayOfStrings(x));
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>isArrayOfStrings : Symbol(isArrayOfStrings, Decl(assertionTypePredicates1.ts, 0, 59))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x[0].length;
|
||||
>x[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(x);
|
||||
>assertIsArrayOfStrings : Symbol(assertIsArrayOfStrings, Decl(assertionTypePredicates1.ts, 5, 73))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x[0].length;
|
||||
>x[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x; // string | undefined
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
assertDefined(x);
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
|
||||
x; // string
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
}
|
||||
}
|
||||
|
||||
function f02(x: string | undefined) {
|
||||
>f02 : Symbol(f02, Decl(assertionTypePredicates1.ts, 36, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
|
||||
if (!!true) {
|
||||
assert(x);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x !== undefined);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assertDefined(x);
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 38, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
function f03(x: string | undefined, assert: (value: unknown) => asserts value) {
|
||||
>f03 : Symbol(f03, Decl(assertionTypePredicates1.ts, 51, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 53, 35))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 53, 45))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 53, 45))
|
||||
|
||||
assert(x);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 53, 35))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 53, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
namespace Debug {
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1))
|
||||
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 58, 17))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 59, 35))
|
||||
>message : Symbol(message, Decl(assertionTypePredicates1.ts, 59, 50))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 59, 35))
|
||||
|
||||
export declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 59, 84))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 60, 45))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 60, 45))
|
||||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 60, 42))
|
||||
}
|
||||
|
||||
function f10(x: string | undefined) {
|
||||
>f10 : Symbol(f10, Decl(assertionTypePredicates1.ts, 61, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
|
||||
if (!!true) {
|
||||
Debug.assert(x);
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(x !== undefined);
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 58, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assertDefined(x);
|
||||
>Debug.assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 59, 84))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 56, 1))
|
||||
>assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 59, 84))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 63, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
|
||||
assert(value: unknown): asserts value {
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11))
|
||||
|
||||
if (value) return;
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 79, 11))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
isTest2(): this is Test2 {
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1))
|
||||
|
||||
return this instanceof Test2;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1))
|
||||
}
|
||||
assertIsTest2(): asserts this is Test2 {
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1))
|
||||
|
||||
if (this instanceof Test2) return;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
assertThis(): asserts this {
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5))
|
||||
|
||||
if (!this) return;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
bar() {
|
||||
>bar : Symbol(Test.bar, Decl(assertionTypePredicates1.ts, 93, 5))
|
||||
|
||||
this.assertThis();
|
||||
>this.assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 89, 5))
|
||||
|
||||
this;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
}
|
||||
foo(x: unknown) {
|
||||
>foo : Symbol(Test.foo, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8))
|
||||
|
||||
this.assert(typeof x === "string");
|
||||
>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 98, 8))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
if (this.isTest2()) {
|
||||
>this.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 82, 5))
|
||||
|
||||
this.z;
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26))
|
||||
}
|
||||
this.assertIsTest2();
|
||||
>this.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 85, 5))
|
||||
|
||||
this.z;
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26))
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Test {
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 107, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
|
||||
|
||||
z = 0;
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 109, 26))
|
||||
}
|
||||
|
||||
// Invalid constructs
|
||||
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
>Q1 : Symbol(Q1, Decl(assertionTypePredicates1.ts, 115, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 115, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 115, 21))
|
||||
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
>Q2 : Symbol(Q2, Decl(assertionTypePredicates1.ts, 116, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 116, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 116, 21))
|
||||
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
>Q3 : Symbol(Q3, Decl(assertionTypePredicates1.ts, 117, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 117, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 117, 21))
|
||||
|
||||
declare class Wat {
|
||||
>Wat : Symbol(Wat, Decl(assertionTypePredicates1.ts, 117, 56))
|
||||
|
||||
get p1(): this is string;
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 119, 19), Decl(assertionTypePredicates1.ts, 120, 29))
|
||||
|
||||
set p1(x: this is string);
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 119, 19), Decl(assertionTypePredicates1.ts, 120, 29))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 121, 11))
|
||||
|
||||
get p2(): asserts this is string;
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 121, 30), Decl(assertionTypePredicates1.ts, 122, 37))
|
||||
|
||||
set p2(x: asserts this is string);
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 121, 30), Decl(assertionTypePredicates1.ts, 122, 37))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 123, 11))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
=== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts ===
|
||||
declare function isString(value: unknown): value is string;
|
||||
>isString : (value: unknown) => value is string
|
||||
>value : unknown
|
||||
|
||||
declare function isArrayOfStrings(value: unknown): value is string[];
|
||||
>isArrayOfStrings : (value: unknown) => value is string[]
|
||||
>value : unknown
|
||||
|
||||
const assert: (value: unknown) => asserts value = value => {}
|
||||
>assert : (value: unknown) => asserts value
|
||||
>value : unknown
|
||||
>value => {} : (value: unknown) => void
|
||||
>value : unknown
|
||||
|
||||
declare function assertIsString(value: unknown): asserts value is string;
|
||||
>assertIsString : (value: unknown) => asserts value is string
|
||||
>value : unknown
|
||||
|
||||
declare function assertIsArrayOfStrings(value: unknown): asserts value is string[];
|
||||
>assertIsArrayOfStrings : (value: unknown) => asserts value is string[]
|
||||
>value : unknown
|
||||
|
||||
declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
>assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>value : T
|
||||
|
||||
function f01(x: unknown) {
|
||||
>f01 : (x: unknown) => void
|
||||
>x : unknown
|
||||
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(typeof x === "string");
|
||||
>assert(typeof x === "string") : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"string" : "string"
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(x instanceof Error);
|
||||
>assert(x instanceof Error) : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>x instanceof Error : boolean
|
||||
>x : unknown
|
||||
>Error : ErrorConstructor
|
||||
|
||||
x.message;
|
||||
>x.message : string
|
||||
>x : Error
|
||||
>message : string
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(typeof x === "boolean" || typeof x === "number");
|
||||
>assert(typeof x === "boolean" || typeof x === "number") : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>typeof x === "boolean" || typeof x === "number" : boolean
|
||||
>typeof x === "boolean" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"boolean" : "boolean"
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"number" : "number"
|
||||
|
||||
x.toLocaleString;
|
||||
>x.toLocaleString : ((locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined) => string) | (() => string)
|
||||
>x : number | boolean
|
||||
>toLocaleString : ((locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined) => string) | (() => string)
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(isArrayOfStrings(x));
|
||||
>assert(isArrayOfStrings(x)) : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>isArrayOfStrings(x) : boolean
|
||||
>isArrayOfStrings : (value: unknown) => value is string[]
|
||||
>x : unknown
|
||||
|
||||
x[0].length;
|
||||
>x[0].length : number
|
||||
>x[0] : string
|
||||
>x : string[]
|
||||
>0 : 0
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assertIsArrayOfStrings(x);
|
||||
>assertIsArrayOfStrings(x) : void
|
||||
>assertIsArrayOfStrings : (value: unknown) => asserts value is string[]
|
||||
>x : unknown
|
||||
|
||||
x[0].length;
|
||||
>x[0].length : number
|
||||
>x[0] : string
|
||||
>x : string[]
|
||||
>0 : 0
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(x === undefined || typeof x === "string");
|
||||
>assert(x === undefined || typeof x === "string") : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>x === undefined || typeof x === "string" : boolean
|
||||
>x === undefined : boolean
|
||||
>x : unknown
|
||||
>undefined : undefined
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"string" : "string"
|
||||
|
||||
x; // string | undefined
|
||||
>x : string | undefined
|
||||
|
||||
assertDefined(x);
|
||||
>assertDefined(x) : void
|
||||
>assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>x : string | undefined
|
||||
|
||||
x; // string
|
||||
>x : string
|
||||
}
|
||||
}
|
||||
|
||||
function f02(x: string | undefined) {
|
||||
>f02 : (x: string | undefined) => void
|
||||
>x : string | undefined
|
||||
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(x);
|
||||
>assert(x) : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>x : string | undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(x !== undefined);
|
||||
>assert(x !== undefined) : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>x !== undefined : boolean
|
||||
>x : string | undefined
|
||||
>undefined : undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assertDefined(x);
|
||||
>assertDefined(x) : void
|
||||
>assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>x : string | undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
}
|
||||
|
||||
function f03(x: string | undefined, assert: (value: unknown) => asserts value) {
|
||||
>f03 : (x: string | undefined, assert: (value: unknown) => asserts value) => void
|
||||
>x : string | undefined
|
||||
>assert : (value: unknown) => asserts value
|
||||
>value : unknown
|
||||
|
||||
assert(x);
|
||||
>assert(x) : void
|
||||
>assert : (value: unknown) => asserts value
|
||||
>x : string | undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
|
||||
namespace Debug {
|
||||
>Debug : typeof Debug
|
||||
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
>assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>value : unknown
|
||||
>message : string | undefined
|
||||
|
||||
export declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
>assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>value : T
|
||||
}
|
||||
|
||||
function f10(x: string | undefined) {
|
||||
>f10 : (x: string | undefined) => void
|
||||
>x : string | undefined
|
||||
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
Debug.assert(x);
|
||||
>Debug.assert(x) : void
|
||||
>Debug.assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>Debug : typeof Debug
|
||||
>assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>x : string | undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
Debug.assert(x !== undefined);
|
||||
>Debug.assert(x !== undefined) : void
|
||||
>Debug.assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>Debug : typeof Debug
|
||||
>assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>x !== undefined : boolean
|
||||
>x : string | undefined
|
||||
>undefined : undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
Debug.assertDefined(x);
|
||||
>Debug.assertDefined(x) : void
|
||||
>Debug.assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>Debug : typeof Debug
|
||||
>assertDefined : <T>(value: T) => asserts value is NonNullable<T>
|
||||
>x : string | undefined
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
|
||||
assert(value: unknown): asserts value {
|
||||
>assert : (value: unknown) => asserts value
|
||||
>value : unknown
|
||||
|
||||
if (value) return;
|
||||
>value : unknown
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
isTest2(): this is Test2 {
|
||||
>isTest2 : () => this is Test2
|
||||
|
||||
return this instanceof Test2;
|
||||
>this instanceof Test2 : boolean
|
||||
>this : this
|
||||
>Test2 : typeof Test2
|
||||
}
|
||||
assertIsTest2(): asserts this is Test2 {
|
||||
>assertIsTest2 : () => asserts this is Test2
|
||||
|
||||
if (this instanceof Test2) return;
|
||||
>this instanceof Test2 : boolean
|
||||
>this : this
|
||||
>Test2 : typeof Test2
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
assertThis(): asserts this {
|
||||
>assertThis : () => asserts this
|
||||
|
||||
if (!this) return;
|
||||
>!this : false
|
||||
>this : this
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
bar() {
|
||||
>bar : () => void
|
||||
|
||||
this.assertThis();
|
||||
>this.assertThis() : void
|
||||
>this.assertThis : () => asserts this
|
||||
>this : this
|
||||
>assertThis : () => asserts this
|
||||
|
||||
this;
|
||||
>this : this
|
||||
}
|
||||
foo(x: unknown) {
|
||||
>foo : (x: unknown) => void
|
||||
>x : unknown
|
||||
|
||||
this.assert(typeof x === "string");
|
||||
>this.assert(typeof x === "string") : void
|
||||
>this.assert : (value: unknown) => asserts value
|
||||
>this : this
|
||||
>assert : (value: unknown) => asserts value
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"string" : "string"
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
|
||||
if (this.isTest2()) {
|
||||
>this.isTest2() : boolean
|
||||
>this.isTest2 : () => this is Test2
|
||||
>this : this
|
||||
>isTest2 : () => this is Test2
|
||||
|
||||
this.z;
|
||||
>this.z : number
|
||||
>this : this & Test2
|
||||
>z : number
|
||||
}
|
||||
this.assertIsTest2();
|
||||
>this.assertIsTest2() : void
|
||||
>this.assertIsTest2 : () => asserts this is Test2
|
||||
>this : this
|
||||
>assertIsTest2 : () => asserts this is Test2
|
||||
|
||||
this.z;
|
||||
>this.z : number
|
||||
>this : this & Test2
|
||||
>z : number
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Test {
|
||||
>Test2 : Test2
|
||||
>Test : Test
|
||||
|
||||
z = 0;
|
||||
>z : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
// Invalid constructs
|
||||
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
>Q1 : new (x: unknown) => x is string
|
||||
>x : unknown
|
||||
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
>Q2 : new (x: boolean) => asserts x
|
||||
>x : boolean
|
||||
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
>Q3 : new (x: unknown) => asserts x is string
|
||||
>x : unknown
|
||||
|
||||
declare class Wat {
|
||||
>Wat : Wat
|
||||
|
||||
get p1(): this is string;
|
||||
>p1 : boolean
|
||||
|
||||
set p1(x: this is string);
|
||||
>p1 : boolean
|
||||
>x : boolean
|
||||
|
||||
get p2(): asserts this is string;
|
||||
>p2 : void
|
||||
|
||||
set p2(x: asserts this is string);
|
||||
>p2 : void
|
||||
>x : void
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js(46,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js(58,5): error TS7027: Unreachable code detected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js (2 errors) ====
|
||||
/** @typedef {(check: boolean) => asserts check} AssertFunc */
|
||||
|
||||
/** @type {AssertFunc} */
|
||||
const assert = check => {
|
||||
if (!check) throw new Error();
|
||||
}
|
||||
|
||||
/** @type {(x: unknown) => asserts x is string } */
|
||||
function assertIsString(x) {
|
||||
if (!(typeof x === "string")) throw new Error();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} check
|
||||
* @returns {asserts check}
|
||||
*/
|
||||
function assert2(check) {
|
||||
if (!check) throw new Error();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {never}
|
||||
*/
|
||||
function fail() {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} x
|
||||
*/
|
||||
function f1(x) {
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assert2(typeof x === "string");
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsString(x);
|
||||
x.length;
|
||||
}
|
||||
if (!!true) {
|
||||
fail();
|
||||
x; // Unreachable
|
||||
~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} b
|
||||
*/
|
||||
function f2(b) {
|
||||
switch (b) {
|
||||
case true: return 1;
|
||||
case false: return 0;
|
||||
}
|
||||
b; // Unreachable
|
||||
~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
=== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js ===
|
||||
/** @typedef {(check: boolean) => asserts check} AssertFunc */
|
||||
|
||||
/** @type {AssertFunc} */
|
||||
const assert = check => {
|
||||
>assert : Symbol(assert, Decl(assertionsAndNonReturningFunctions.js, 3, 5))
|
||||
>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 3, 14))
|
||||
|
||||
if (!check) throw new Error();
|
||||
>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 3, 14))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
/** @type {(x: unknown) => asserts x is string } */
|
||||
function assertIsString(x) {
|
||||
>assertIsString : Symbol(assertIsString, Decl(assertionsAndNonReturningFunctions.js, 5, 1))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 8, 24))
|
||||
|
||||
if (!(typeof x === "string")) throw new Error();
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 8, 24))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} check
|
||||
* @returns {asserts check}
|
||||
*/
|
||||
function assert2(check) {
|
||||
>assert2 : Symbol(assert2, Decl(assertionsAndNonReturningFunctions.js, 10, 1))
|
||||
>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 16, 17))
|
||||
|
||||
if (!check) throw new Error();
|
||||
>check : Symbol(check, Decl(assertionsAndNonReturningFunctions.js, 16, 17))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {never}
|
||||
*/
|
||||
function fail() {
|
||||
>fail : Symbol(fail, Decl(assertionsAndNonReturningFunctions.js, 18, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} x
|
||||
*/
|
||||
function f1(x) {
|
||||
>f1 : Symbol(f1, Decl(assertionsAndNonReturningFunctions.js, 25, 1))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
|
||||
if (!!true) {
|
||||
assert(typeof x === "string");
|
||||
>assert : Symbol(assert, Decl(assertionsAndNonReturningFunctions.js, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert2(typeof x === "string");
|
||||
>assert2 : Symbol(assert2, Decl(assertionsAndNonReturningFunctions.js, 10, 1))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsString(x);
|
||||
>assertIsString : Symbol(assertIsString, Decl(assertionsAndNonReturningFunctions.js, 5, 1))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
fail();
|
||||
>fail : Symbol(fail, Decl(assertionsAndNonReturningFunctions.js, 18, 1))
|
||||
|
||||
x; // Unreachable
|
||||
>x : Symbol(x, Decl(assertionsAndNonReturningFunctions.js, 30, 12))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} b
|
||||
*/
|
||||
function f2(b) {
|
||||
>f2 : Symbol(f2, Decl(assertionsAndNonReturningFunctions.js, 47, 1))
|
||||
>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12))
|
||||
|
||||
switch (b) {
|
||||
>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12))
|
||||
|
||||
case true: return 1;
|
||||
case false: return 0;
|
||||
}
|
||||
b; // Unreachable
|
||||
>b : Symbol(b, Decl(assertionsAndNonReturningFunctions.js, 52, 12))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
=== tests/cases/conformance/jsdoc/assertionsAndNonReturningFunctions.js ===
|
||||
/** @typedef {(check: boolean) => asserts check} AssertFunc */
|
||||
|
||||
/** @type {AssertFunc} */
|
||||
const assert = check => {
|
||||
>assert : (check: boolean) => asserts check
|
||||
>check => { if (!check) throw new Error();} : (check: boolean) => asserts check
|
||||
>check : boolean
|
||||
|
||||
if (!check) throw new Error();
|
||||
>!check : boolean
|
||||
>check : boolean
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
|
||||
/** @type {(x: unknown) => asserts x is string } */
|
||||
function assertIsString(x) {
|
||||
>assertIsString : (x: unknown) => asserts x is string
|
||||
>x : unknown
|
||||
|
||||
if (!(typeof x === "string")) throw new Error();
|
||||
>!(typeof x === "string") : boolean
|
||||
>(typeof x === "string") : boolean
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : unknown
|
||||
>"string" : "string"
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} check
|
||||
* @returns {asserts check}
|
||||
*/
|
||||
function assert2(check) {
|
||||
>assert2 : (check: boolean) => asserts check
|
||||
>check : boolean
|
||||
|
||||
if (!check) throw new Error();
|
||||
>!check : boolean
|
||||
>check : boolean
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {never}
|
||||
*/
|
||||
function fail() {
|
||||
>fail : () => never
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} x
|
||||
*/
|
||||
function f1(x) {
|
||||
>f1 : (x: any) => void
|
||||
>x : any
|
||||
|
||||
if (!!true) {
|
||||
>!!true : boolean
|
||||
>!true : boolean
|
||||
>true : true
|
||||
|
||||
assert(typeof x === "string");
|
||||
>assert(typeof x === "string") : void
|
||||
>assert : (check: boolean) => asserts check
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : any
|
||||
>"string" : "string"
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : boolean
|
||||
>!true : boolean
|
||||
>true : true
|
||||
|
||||
assert2(typeof x === "string");
|
||||
>assert2(typeof x === "string") : void
|
||||
>assert2 : (check: boolean) => asserts check
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>x : any
|
||||
>"string" : "string"
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : boolean
|
||||
>!true : boolean
|
||||
>true : true
|
||||
|
||||
assertIsString(x);
|
||||
>assertIsString(x) : void
|
||||
>assertIsString : (x: unknown) => asserts x is string
|
||||
>x : any
|
||||
|
||||
x.length;
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : boolean
|
||||
>!true : boolean
|
||||
>true : true
|
||||
|
||||
fail();
|
||||
>fail() : never
|
||||
>fail : () => never
|
||||
|
||||
x; // Unreachable
|
||||
>x : any
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} b
|
||||
*/
|
||||
function f2(b) {
|
||||
>f2 : (b: boolean) => 1 | 0
|
||||
>b : boolean
|
||||
|
||||
switch (b) {
|
||||
>b : boolean
|
||||
|
||||
case true: return 1;
|
||||
>true : true
|
||||
>1 : 1
|
||||
|
||||
case false: return 0;
|
||||
>false : false
|
||||
>0 : 0
|
||||
}
|
||||
b; // Unreachable
|
||||
>b : never
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(14,1): error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'.
|
||||
Types of property 'valueOf' are incompatible.
|
||||
Type '() => Object' is not assignable to type '() => boolean'.
|
||||
Type 'Object' is not assignable to type 'boolean'.
|
||||
The types returned by 'valueOf()' are incompatible between these types.
|
||||
Type 'Object' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'.
|
||||
'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible.
|
||||
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'.
|
||||
@@ -24,9 +23,8 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(
|
||||
a = b;
|
||||
~
|
||||
!!! error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'.
|
||||
!!! error TS2322: Types of property 'valueOf' are incompatible.
|
||||
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: The types returned by 'valueOf()' are incompatible between these types.
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.
|
||||
|
||||
b = a;
|
||||
b = x;
|
||||
|
||||
@@ -5,10 +5,9 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
Type 'Thenable' is not assignable to type 'PromiseLike<T>'.
|
||||
Types of property 'then' are incompatible.
|
||||
Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
|
||||
Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
|
||||
Construct signature return types 'Thenable' and 'PromiseLike<T>' are incompatible.
|
||||
The types returned by 'then(...)' are incompatible between these types.
|
||||
Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
|
||||
|
||||
@@ -38,10 +37,9 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
|
||||
async function fn6(): Thenable { } // error
|
||||
~~~~~~~~
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike<T>'.
|
||||
!!! error TS1055: Types of property 'then' are incompatible.
|
||||
!!! error TS1055: Type '() => void' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
|
||||
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
|
||||
!!! error TS1055: Construct signature return types 'Thenable' and 'PromiseLike<T>' are incompatible.
|
||||
!!! error TS1055: The types returned by 'then(...)' are incompatible between these types.
|
||||
!!! error TS1055: Type 'void' is not assignable to type 'PromiseLike<TResult1 | TResult2>'.
|
||||
async function fn7() { return; } // valid: Promise<void>
|
||||
async function fn8() { return 1; } // valid: Promise<number>
|
||||
async function fn9() { return null; } // valid: Promise<any>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
tests/cases/compiler/baseConstraintOfDecorator.ts(2,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
|
||||
'typeof decoratorFunc' is assignable to the constraint of type 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/compiler/baseConstraintOfDecorator.ts(2,40): error TS2507: Type 'TFunction' is not a constructor function type.
|
||||
tests/cases/compiler/baseConstraintOfDecorator.ts(12,5): error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
|
||||
tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TFunction' is not a constructor function type.
|
||||
tests/cases/compiler/baseConstraintOfDecorator.ts(12,18): error TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/baseConstraintOfDecorator.ts (4 errors) ====
|
||||
==== tests/cases/compiler/baseConstraintOfDecorator.ts (3 errors) ====
|
||||
export function classExtender<TFunction>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
|
||||
return class decoratorFunc extends superClass {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -29,20 +28,12 @@ tests/cases/compiler/baseConstraintOfDecorator.ts(12,40): error TS2507: Type 'TF
|
||||
class MyClass { private x; }
|
||||
export function classExtender2<TFunction extends new (...args: string[]) => MyClass>(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction {
|
||||
return class decoratorFunc extends superClass {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
!!! error TS2507: Type 'TFunction' is not a constructor function type.
|
||||
!!! related TS2735 tests/cases/compiler/baseConstraintOfDecorator.ts:11:32: Did you mean for 'TFunction' to be constrained to type 'new (...args: any[]) => MyClass'?
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'.
|
||||
constructor(...args: any[]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
super(...args);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_instanceModifier(this, args);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~~~~~
|
||||
};
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'typeof decoratorFunc' is not assignable to type 'TFunction'.
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ export function classExtender2<TFunction extends new (...args: string[]) => MyCl
|
||||
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20))
|
||||
|
||||
super(...args);
|
||||
>super : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 10, 31))
|
||||
>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 12, 20))
|
||||
|
||||
_instanceModifier(this, args);
|
||||
|
||||
@@ -42,16 +42,16 @@ export function classExtender2<TFunction extends new (...args: string[]) => MyCl
|
||||
>args : any[]
|
||||
|
||||
return class decoratorFunc extends superClass {
|
||||
>class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : typeof decoratorFunc
|
||||
>decoratorFunc : typeof decoratorFunc
|
||||
>superClass : TFunction
|
||||
>class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : { new (...args: any[]): decoratorFunc; prototype: classExtender2<any>.decoratorFunc; } & TFunction
|
||||
>decoratorFunc : { new (...args: any[]): decoratorFunc; prototype: classExtender2<any>.decoratorFunc; } & TFunction
|
||||
>superClass : MyClass
|
||||
|
||||
constructor(...args: any[]) {
|
||||
>args : any[]
|
||||
|
||||
super(...args);
|
||||
>super(...args) : void
|
||||
>super : any
|
||||
>super : TFunction
|
||||
>...args : any
|
||||
>args : any[]
|
||||
|
||||
|
||||
@@ -4,15 +4,11 @@ tests/cases/compiler/bigintWithLib.ts(16,33): error TS2769: No overload matches
|
||||
Argument of type 'number[]' is not assignable to parameter of type 'number'.
|
||||
Overload 2 of 3, '(array: Iterable<bigint>): BigInt64Array', gave the following error.
|
||||
Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
|
||||
Types of property '[Symbol.iterator]' are incompatible.
|
||||
Type '() => IterableIterator<number>' is not assignable to type '() => Iterator<bigint, any, undefined>'.
|
||||
Type 'IterableIterator<number>' is not assignable to type 'Iterator<bigint, any, undefined>'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(...args: [] | [undefined]) => IteratorResult<number, any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<bigint, any>'.
|
||||
Type 'IteratorResult<number, any>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<bigint>'.
|
||||
Type 'number' is not assignable to type 'bigint'.
|
||||
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
Type 'IteratorResult<number, any>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<bigint>'.
|
||||
Type 'number' is not assignable to type 'bigint'.
|
||||
Overload 3 of 3, '(buffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): BigInt64Array', gave the following error.
|
||||
Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
|
||||
Type 'number[]' is missing the following properties from type 'SharedArrayBuffer': byteLength, [Symbol.species], [Symbol.toStringTag]
|
||||
@@ -55,15 +51,11 @@ tests/cases/compiler/bigintWithLib.ts(43,26): error TS2345: Argument of type '12
|
||||
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'number'.
|
||||
!!! error TS2769: Overload 2 of 3, '(array: Iterable<bigint>): BigInt64Array', gave the following error.
|
||||
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
|
||||
!!! error TS2769: Types of property '[Symbol.iterator]' are incompatible.
|
||||
!!! error TS2769: Type '() => IterableIterator<number>' is not assignable to type '() => Iterator<bigint, any, undefined>'.
|
||||
!!! error TS2769: Type 'IterableIterator<number>' is not assignable to type 'Iterator<bigint, any, undefined>'.
|
||||
!!! error TS2769: Types of property 'next' are incompatible.
|
||||
!!! error TS2769: Type '(...args: [] | [undefined]) => IteratorResult<number, any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<bigint, any>'.
|
||||
!!! error TS2769: Type 'IteratorResult<number, any>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<bigint>'.
|
||||
!!! error TS2769: Type 'number' is not assignable to type 'bigint'.
|
||||
!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
!!! error TS2769: Type 'IteratorResult<number, any>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<bigint, any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<bigint>'.
|
||||
!!! error TS2769: Type 'number' is not assignable to type 'bigint'.
|
||||
!!! error TS2769: Overload 3 of 3, '(buffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): BigInt64Array', gave the following error.
|
||||
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBuffer | SharedArrayBuffer'.
|
||||
!!! error TS2769: Type 'number[]' is missing the following properties from type 'SharedArrayBuffer': byteLength, [Symbol.species], [Symbol.toStringTag]
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type '1' is not assignable to type 'Boolean'.
|
||||
tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type '"a"' is not assignable to type 'Boolean'.
|
||||
tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'.
|
||||
Types of property 'valueOf' are incompatible.
|
||||
Type '() => Object' is not assignable to type '() => boolean'.
|
||||
Type 'Object' is not assignable to type 'boolean'.
|
||||
The types returned by 'valueOf()' are incompatible between these types.
|
||||
Type 'Object' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/booleanAssignment.ts (3 errors) ====
|
||||
@@ -17,9 +16,8 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a
|
||||
b = {}; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'Boolean'.
|
||||
!!! error TS2322: Types of property 'valueOf' are incompatible.
|
||||
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: The types returned by 'valueOf()' are incompatible between these types.
|
||||
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.
|
||||
|
||||
var o = {};
|
||||
o = b; // OK
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts(57,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type '(x: number) => string' is not assignable to type '(x: number) => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'a(...)' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts(63,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type '<T>(x: T) => string' is not assignable to type '<T>(x: T) => T'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
The types returned by 'a2(...)' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts (2 errors) ====
|
||||
@@ -69,9 +67,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
interface I2 extends Base2 {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'.
|
||||
!!! error TS2430: Types of property 'a' are incompatible.
|
||||
!!! error TS2430: Type '(x: number) => string' is not assignable to type '(x: number) => number'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2430: The types returned by 'a(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
// N's
|
||||
a: (x: number) => string; // error because base returns non-void;
|
||||
}
|
||||
@@ -80,10 +77,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
interface I3 extends Base2 {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type '<T>(x: T) => string' is not assignable to type '<T>(x: T) => T'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
// N's
|
||||
a2: <T>(x: T) => string; // error because base returns non-void;
|
||||
}
|
||||
|
||||
@@ -27,16 +27,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(100,19): error TS2430: Interface 'I6' incorrectly extends interface 'B'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type '<T>(x: T) => string[]' is not assignable to type '<T>(x: T) => T[]'.
|
||||
Type 'string[]' is not assignable to type 'T[]'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
The types returned by 'a2(...)' are incompatible between these types.
|
||||
Type 'string[]' is not assignable to type 'T[]'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(109,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type '<T>(x: T) => T[]' is not assignable to type '<T>(x: T) => string[]'.
|
||||
Type 'T[]' is not assignable to type 'string[]'.
|
||||
Type 'T' is not assignable to type 'string'.
|
||||
The types returned by 'a2(...)' are incompatible between these types.
|
||||
Type 'T[]' is not assignable to type 'string[]'.
|
||||
Type 'T' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts (6 errors) ====
|
||||
@@ -174,11 +172,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
interface I6 extends B {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I6' incorrectly extends interface 'B'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type '<T>(x: T) => string[]' is not assignable to type '<T>(x: T) => T[]'.
|
||||
!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
a2: <T>(x: T) => string[]; // error
|
||||
}
|
||||
|
||||
@@ -190,10 +187,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
interface I7 extends C {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I7' incorrectly extends interface 'C'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type '<T>(x: T) => T[]' is not assignable to type '<T>(x: T) => string[]'.
|
||||
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2430: The types returned by 'a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'string'.
|
||||
a2: <T>(x: T) => T[]; // error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/conformance/jsx/checkJsxChildrenCanBeTupleType.tsx(17,18): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(props: Readonly<ResizablePanelProps>): ResizablePanel', gave the following error.
|
||||
Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly<ResizablePanelProps>'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '[Element, Element, Element]' is not assignable to type '[ReactNode, ReactNode]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '3' is not assignable to type '2'.
|
||||
The types of 'children.length' are incompatible between these types.
|
||||
Type '3' is not assignable to type '2'.
|
||||
Overload 2 of 2, '(props: ResizablePanelProps, context?: any): ResizablePanel', gave the following error.
|
||||
Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly<ResizablePanelProps>'.
|
||||
Types of property 'children' are incompatible.
|
||||
@@ -33,10 +31,8 @@ tests/cases/conformance/jsx/checkJsxChildrenCanBeTupleType.tsx(17,18): error TS2
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(props: Readonly<ResizablePanelProps>): ResizablePanel', gave the following error.
|
||||
!!! error TS2769: Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly<ResizablePanelProps>'.
|
||||
!!! error TS2769: Types of property 'children' are incompatible.
|
||||
!!! error TS2769: Type '[Element, Element, Element]' is not assignable to type '[ReactNode, ReactNode]'.
|
||||
!!! error TS2769: Types of property 'length' are incompatible.
|
||||
!!! error TS2769: Type '3' is not assignable to type '2'.
|
||||
!!! error TS2769: The types of 'children.length' are incompatible between these types.
|
||||
!!! error TS2769: Type '3' is not assignable to type '2'.
|
||||
!!! error TS2769: Overload 2 of 2, '(props: ResizablePanelProps, context?: any): ResizablePanel', gave the following error.
|
||||
!!! error TS2769: Type '{ children: [Element, Element, Element]; }' is not assignable to type 'Readonly<ResizablePanelProps>'.
|
||||
!!! error TS2769: Types of property 'children' are incompatible.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/jsx/file.tsx(10,13): error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(10,17): error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'children' does not exist on type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(11,13): error TS2322: Type '{ children: Element; key: string; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'children' does not exist on type 'IntrinsicAttributes'.
|
||||
@@ -17,7 +17,7 @@ tests/cases/conformance/jsx/file.tsx(12,13): error TS2322: Type '{ children: Ele
|
||||
|
||||
// Not OK (excess children)
|
||||
const k3 = <Tag children={<div></div>} />;
|
||||
~~~
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes'.
|
||||
const k4 = <Tag key="1"><div></div></Tag>;
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
|
||||
Types of property 'toSeq' are incompatible.
|
||||
Type '() => Keyed<K, V>' is not assignable to type '() => this'.
|
||||
Type 'Keyed<K, V>' is not assignable to type 'this'.
|
||||
'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
|
||||
The types returned by 'toSeq()' are incompatible between these types.
|
||||
Type 'Keyed<K, V>' is not assignable to type 'this'.
|
||||
'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
|
||||
tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
|
||||
Types of property 'toSeq' are incompatible.
|
||||
Type '() => Indexed<T>' is not assignable to type '() => this'.
|
||||
Type 'Indexed<T>' is not assignable to type 'this'.
|
||||
'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
|
||||
The types returned by 'toSeq()' are incompatible between these types.
|
||||
Type 'Indexed<T>' is not assignable to type 'this'.
|
||||
'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
|
||||
tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
|
||||
Types of property 'toSeq' are incompatible.
|
||||
Type '() => Set<T>' is not assignable to type '() => this'.
|
||||
Type 'Set<T>' is not assignable to type 'this'.
|
||||
'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
|
||||
The types returned by 'toSeq()' are incompatible between these types.
|
||||
Type 'Set<T>' is not assignable to type 'this'.
|
||||
'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/complex.ts (0 errors) ====
|
||||
@@ -380,10 +377,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
|
||||
export interface Keyed<K, V> extends Collection<K, V> {
|
||||
~~~~~
|
||||
!!! error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
|
||||
!!! error TS2430: Types of property 'toSeq' are incompatible.
|
||||
!!! error TS2430: Type '() => Keyed<K, V>' is not assignable to type '() => this'.
|
||||
!!! error TS2430: Type 'Keyed<K, V>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
|
||||
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
|
||||
!!! error TS2430: Type 'Keyed<K, V>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
|
||||
toJS(): Object;
|
||||
toJSON(): { [key: string]: V };
|
||||
toSeq(): Seq.Keyed<K, V>;
|
||||
@@ -404,10 +400,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
|
||||
export interface Indexed<T> extends Collection<number, T> {
|
||||
~~~~~~~
|
||||
!!! error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
|
||||
!!! error TS2430: Types of property 'toSeq' are incompatible.
|
||||
!!! error TS2430: Type '() => Indexed<T>' is not assignable to type '() => this'.
|
||||
!!! error TS2430: Type 'Indexed<T>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
|
||||
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
|
||||
!!! error TS2430: Type 'Indexed<T>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
|
||||
toJS(): Array<any>;
|
||||
toJSON(): Array<T>;
|
||||
// Reading values
|
||||
@@ -442,10 +437,9 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
|
||||
export interface Set<T> extends Collection<never, T> {
|
||||
~~~
|
||||
!!! error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
|
||||
!!! error TS2430: Types of property 'toSeq' are incompatible.
|
||||
!!! error TS2430: Type '() => Set<T>' is not assignable to type '() => this'.
|
||||
!!! error TS2430: Type 'Set<T>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
|
||||
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
|
||||
!!! error TS2430: Type 'Set<T>' is not assignable to type 'this'.
|
||||
!!! error TS2430: 'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
|
||||
toJS(): Array<any>;
|
||||
toJSON(): Array<T>;
|
||||
toSeq(): Seq.Set<T>;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts(61,15): error TS2430: Interface 'I2' incorrectly extends interface 'Base2'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'new (x: number) => string' is not assignable to type 'new (x: number) => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'new a(...)' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts(67,15): error TS2430: Interface 'I3' incorrectly extends interface 'Base2'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type 'new <T>(x: T) => string' is not assignable to type 'new <T>(x: T) => T'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
The types returned by 'new a2(...)' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance.ts (2 errors) ====
|
||||
@@ -73,9 +71,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
|
||||
interface I2 extends Base2 {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I2' incorrectly extends interface 'Base2'.
|
||||
!!! error TS2430: Types of property 'a' are incompatible.
|
||||
!!! error TS2430: Type 'new (x: number) => string' is not assignable to type 'new (x: number) => number'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2430: The types returned by 'new a(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
// N's
|
||||
a: new (x: number) => string; // error because base returns non-void;
|
||||
}
|
||||
@@ -84,10 +81,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
|
||||
interface I3 extends Base2 {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I3' incorrectly extends interface 'Base2'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type 'new <T>(x: T) => string' is not assignable to type 'new <T>(x: T) => T'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
// N's
|
||||
a2: new <T>(x: T) => string; // error because base returns non-void;
|
||||
}
|
||||
|
||||
+14
-18
@@ -27,16 +27,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(86,19): error TS2430: Interface 'I6' incorrectly extends interface 'B'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type 'new <T>(x: T) => string[]' is not assignable to type 'new <T>(x: T) => T[]'.
|
||||
Type 'string[]' is not assignable to type 'T[]'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
The types returned by 'new a2(...)' are incompatible between these types.
|
||||
Type 'string[]' is not assignable to type 'T[]'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(95,19): error TS2430: Interface 'I7' incorrectly extends interface 'C'.
|
||||
Types of property 'a2' are incompatible.
|
||||
Type 'new <T>(x: T) => T[]' is not assignable to type 'new <T>(x: T) => string[]'.
|
||||
Type 'T[]' is not assignable to type 'string[]'.
|
||||
Type 'T' is not assignable to type 'string'.
|
||||
The types returned by 'new a2(...)' are incompatible between these types.
|
||||
Type 'T[]' is not assignable to type 'string[]'.
|
||||
Type 'T' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts (6 errors) ====
|
||||
@@ -160,11 +158,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
|
||||
interface I6 extends B {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I6' incorrectly extends interface 'B'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type 'new <T>(x: T) => string[]' is not assignable to type 'new <T>(x: T) => T[]'.
|
||||
!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string[]' is not assignable to type 'T[]'.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2430: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
a2: new <T>(x: T) => string[]; // error
|
||||
}
|
||||
|
||||
@@ -176,10 +173,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
|
||||
interface I7 extends C {
|
||||
~~
|
||||
!!! error TS2430: Interface 'I7' incorrectly extends interface 'C'.
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type 'new <T>(x: T) => T[]' is not assignable to type 'new <T>(x: T) => string[]'.
|
||||
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'string'.
|
||||
!!! error TS2430: The types returned by 'new a2(...)' are incompatible between these types.
|
||||
!!! error TS2430: Type 'T[]' is not assignable to type 'string[]'.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'string'.
|
||||
a2: new <T>(x: T) => T[]; // error
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [contextualSignatureInstantiation4.ts]
|
||||
// Repros from #32976
|
||||
|
||||
declare class Banana<T extends string> { constructor(a: string, property: T) }
|
||||
|
||||
declare function fruitFactory1<TFruit>(Fruit: new (...args: any[]) => TFruit): TFruit
|
||||
const banana1 = fruitFactory1(Banana) // Banana<any>
|
||||
|
||||
declare function fruitFactory2<TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit): TFruit
|
||||
const banana2 = fruitFactory2(Banana) // Banana<any>
|
||||
|
||||
declare function fruitFactory3<TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit): TFruit
|
||||
const banana3 = fruitFactory3(Banana) // Banana<"foo">
|
||||
|
||||
declare function fruitFactory4<TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit): TFruit
|
||||
const banana4 = fruitFactory4(Banana) // Banana<"foo">
|
||||
|
||||
declare function fruitFactory5<TFruit>(Fruit: new (...args: "foo"[]) => TFruit): TFruit
|
||||
const banana5 = fruitFactory5(Banana) // Banana<"foo">
|
||||
|
||||
|
||||
//// [contextualSignatureInstantiation4.js]
|
||||
"use strict";
|
||||
// Repros from #32976
|
||||
var banana1 = fruitFactory1(Banana); // Banana<any>
|
||||
var banana2 = fruitFactory2(Banana); // Banana<any>
|
||||
var banana3 = fruitFactory3(Banana); // Banana<"foo">
|
||||
var banana4 = fruitFactory4(Banana); // Banana<"foo">
|
||||
var banana5 = fruitFactory5(Banana); // Banana<"foo">
|
||||
@@ -0,0 +1,79 @@
|
||||
=== tests/cases/compiler/contextualSignatureInstantiation4.ts ===
|
||||
// Repros from #32976
|
||||
|
||||
declare class Banana<T extends string> { constructor(a: string, property: T) }
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(contextualSignatureInstantiation4.ts, 2, 21))
|
||||
>a : Symbol(a, Decl(contextualSignatureInstantiation4.ts, 2, 53))
|
||||
>property : Symbol(property, Decl(contextualSignatureInstantiation4.ts, 2, 63))
|
||||
>T : Symbol(T, Decl(contextualSignatureInstantiation4.ts, 2, 21))
|
||||
|
||||
declare function fruitFactory1<TFruit>(Fruit: new (...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory1 : Symbol(fruitFactory1, Decl(contextualSignatureInstantiation4.ts, 2, 78))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 4, 31))
|
||||
>Fruit : Symbol(Fruit, Decl(contextualSignatureInstantiation4.ts, 4, 39))
|
||||
>args : Symbol(args, Decl(contextualSignatureInstantiation4.ts, 4, 51))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 4, 31))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 4, 31))
|
||||
|
||||
const banana1 = fruitFactory1(Banana) // Banana<any>
|
||||
>banana1 : Symbol(banana1, Decl(contextualSignatureInstantiation4.ts, 5, 5))
|
||||
>fruitFactory1 : Symbol(fruitFactory1, Decl(contextualSignatureInstantiation4.ts, 2, 78))
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
|
||||
declare function fruitFactory2<TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory2 : Symbol(fruitFactory2, Decl(contextualSignatureInstantiation4.ts, 5, 37))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 7, 31))
|
||||
>Fruit : Symbol(Fruit, Decl(contextualSignatureInstantiation4.ts, 7, 39))
|
||||
>a : Symbol(a, Decl(contextualSignatureInstantiation4.ts, 7, 51))
|
||||
>args : Symbol(args, Decl(contextualSignatureInstantiation4.ts, 7, 61))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 7, 31))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 7, 31))
|
||||
|
||||
const banana2 = fruitFactory2(Banana) // Banana<any>
|
||||
>banana2 : Symbol(banana2, Decl(contextualSignatureInstantiation4.ts, 8, 5))
|
||||
>fruitFactory2 : Symbol(fruitFactory2, Decl(contextualSignatureInstantiation4.ts, 5, 37))
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
|
||||
declare function fruitFactory3<TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory3 : Symbol(fruitFactory3, Decl(contextualSignatureInstantiation4.ts, 8, 37))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 10, 31))
|
||||
>Fruit : Symbol(Fruit, Decl(contextualSignatureInstantiation4.ts, 10, 39))
|
||||
>a : Symbol(a, Decl(contextualSignatureInstantiation4.ts, 10, 51))
|
||||
>s : Symbol(s, Decl(contextualSignatureInstantiation4.ts, 10, 61))
|
||||
>args : Symbol(args, Decl(contextualSignatureInstantiation4.ts, 10, 71))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 10, 31))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 10, 31))
|
||||
|
||||
const banana3 = fruitFactory3(Banana) // Banana<"foo">
|
||||
>banana3 : Symbol(banana3, Decl(contextualSignatureInstantiation4.ts, 11, 5))
|
||||
>fruitFactory3 : Symbol(fruitFactory3, Decl(contextualSignatureInstantiation4.ts, 8, 37))
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
|
||||
declare function fruitFactory4<TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit): TFruit
|
||||
>fruitFactory4 : Symbol(fruitFactory4, Decl(contextualSignatureInstantiation4.ts, 11, 37))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 13, 31))
|
||||
>Fruit : Symbol(Fruit, Decl(contextualSignatureInstantiation4.ts, 13, 39))
|
||||
>a : Symbol(a, Decl(contextualSignatureInstantiation4.ts, 13, 51))
|
||||
>args : Symbol(args, Decl(contextualSignatureInstantiation4.ts, 13, 61))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 13, 31))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 13, 31))
|
||||
|
||||
const banana4 = fruitFactory4(Banana) // Banana<"foo">
|
||||
>banana4 : Symbol(banana4, Decl(contextualSignatureInstantiation4.ts, 14, 5))
|
||||
>fruitFactory4 : Symbol(fruitFactory4, Decl(contextualSignatureInstantiation4.ts, 11, 37))
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
|
||||
declare function fruitFactory5<TFruit>(Fruit: new (...args: "foo"[]) => TFruit): TFruit
|
||||
>fruitFactory5 : Symbol(fruitFactory5, Decl(contextualSignatureInstantiation4.ts, 14, 37))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 16, 31))
|
||||
>Fruit : Symbol(Fruit, Decl(contextualSignatureInstantiation4.ts, 16, 39))
|
||||
>args : Symbol(args, Decl(contextualSignatureInstantiation4.ts, 16, 51))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 16, 31))
|
||||
>TFruit : Symbol(TFruit, Decl(contextualSignatureInstantiation4.ts, 16, 31))
|
||||
|
||||
const banana5 = fruitFactory5(Banana) // Banana<"foo">
|
||||
>banana5 : Symbol(banana5, Decl(contextualSignatureInstantiation4.ts, 17, 5))
|
||||
>fruitFactory5 : Symbol(fruitFactory5, Decl(contextualSignatureInstantiation4.ts, 14, 37))
|
||||
>Banana : Symbol(Banana, Decl(contextualSignatureInstantiation4.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
=== tests/cases/compiler/contextualSignatureInstantiation4.ts ===
|
||||
// Repros from #32976
|
||||
|
||||
declare class Banana<T extends string> { constructor(a: string, property: T) }
|
||||
>Banana : Banana<T>
|
||||
>a : string
|
||||
>property : T
|
||||
|
||||
declare function fruitFactory1<TFruit>(Fruit: new (...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory1 : <TFruit>(Fruit: new (...args: any[]) => TFruit) => TFruit
|
||||
>Fruit : new (...args: any[]) => TFruit
|
||||
>args : any[]
|
||||
|
||||
const banana1 = fruitFactory1(Banana) // Banana<any>
|
||||
>banana1 : Banana<any>
|
||||
>fruitFactory1(Banana) : Banana<any>
|
||||
>fruitFactory1 : <TFruit>(Fruit: new (...args: any[]) => TFruit) => TFruit
|
||||
>Banana : typeof Banana
|
||||
|
||||
declare function fruitFactory2<TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory2 : <TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit) => TFruit
|
||||
>Fruit : new (a: string, ...args: any[]) => TFruit
|
||||
>a : string
|
||||
>args : any[]
|
||||
|
||||
const banana2 = fruitFactory2(Banana) // Banana<any>
|
||||
>banana2 : Banana<any>
|
||||
>fruitFactory2(Banana) : Banana<any>
|
||||
>fruitFactory2 : <TFruit>(Fruit: new (a: string, ...args: any[]) => TFruit) => TFruit
|
||||
>Banana : typeof Banana
|
||||
|
||||
declare function fruitFactory3<TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit): TFruit
|
||||
>fruitFactory3 : <TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit) => TFruit
|
||||
>Fruit : new (a: string, s: "foo", ...args: any[]) => TFruit
|
||||
>a : string
|
||||
>s : "foo"
|
||||
>args : any[]
|
||||
|
||||
const banana3 = fruitFactory3(Banana) // Banana<"foo">
|
||||
>banana3 : Banana<"foo">
|
||||
>fruitFactory3(Banana) : Banana<"foo">
|
||||
>fruitFactory3 : <TFruit>(Fruit: new (a: string, s: "foo", ...args: any[]) => TFruit) => TFruit
|
||||
>Banana : typeof Banana
|
||||
|
||||
declare function fruitFactory4<TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit): TFruit
|
||||
>fruitFactory4 : <TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit) => TFruit
|
||||
>Fruit : new (a: string, ...args: "foo"[]) => TFruit
|
||||
>a : string
|
||||
>args : "foo"[]
|
||||
|
||||
const banana4 = fruitFactory4(Banana) // Banana<"foo">
|
||||
>banana4 : Banana<"foo">
|
||||
>fruitFactory4(Banana) : Banana<"foo">
|
||||
>fruitFactory4 : <TFruit>(Fruit: new (a: string, ...args: "foo"[]) => TFruit) => TFruit
|
||||
>Banana : typeof Banana
|
||||
|
||||
declare function fruitFactory5<TFruit>(Fruit: new (...args: "foo"[]) => TFruit): TFruit
|
||||
>fruitFactory5 : <TFruit>(Fruit: new (...args: "foo"[]) => TFruit) => TFruit
|
||||
>Fruit : new (...args: "foo"[]) => TFruit
|
||||
>args : "foo"[]
|
||||
|
||||
const banana5 = fruitFactory5(Banana) // Banana<"foo">
|
||||
>banana5 : Banana<"foo">
|
||||
>fruitFactory5(Banana) : Banana<"foo">
|
||||
>fruitFactory5 : <TFruit>(Fruit: new (...args: "foo"[]) => TFruit) => TFruit
|
||||
>Banana : typeof Banana
|
||||
|
||||
+12
-12
@@ -1,34 +1,34 @@
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,13): error TS2769: No overload matches this call.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,64): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error.
|
||||
Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,13): error TS2769: No overload matches this call.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,12): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error.
|
||||
Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,13): error TS2769: No overload matches this call.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,43): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
Type '{ extra: true; goTo: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error.
|
||||
Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,13): error TS2769: No overload matches this call.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,12): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
Type '{ goTo: string; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'goTo' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
Overload 2 of 2, '(linkProps: LinkProps): Element', gave the following error.
|
||||
Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,13): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,65): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err
|
||||
}
|
||||
|
||||
const b0 = <MainButton {...{onClick: (k) => {console.log(k)}}} extra />; // k has type "left" | "right"
|
||||
~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
!!! error TS2769: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
@@ -69,7 +69,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err
|
||||
!!! error TS2769: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2769: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b2 = <MainButton onClick={(k)=>{console.log(k)}} extra />; // k has type "left" | "right"
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
!!! error TS2769: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
@@ -78,7 +78,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err
|
||||
!!! error TS2769: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2769: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "contact"
|
||||
~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
!!! error TS2769: Type '{ extra: true; goTo: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
@@ -87,7 +87,7 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err
|
||||
!!! error TS2769: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2769: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b4 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact"
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(buttonProps: ButtonProps): Element', gave the following error.
|
||||
!!! error TS2769: Type '{ goTo: string; extra: true; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
@@ -98,13 +98,13 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): err
|
||||
|
||||
export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
|
||||
const c1 = <NoOverload {...{onClick: (k) => {console.log(k)}}} extra />; // k has type any
|
||||
~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
|
||||
export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined }
|
||||
const d1 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" | "contact"
|
||||
~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
|
||||
@@ -15,7 +15,7 @@ async function countEverything(): Promise<number> {
|
||||
const [resultA, resultB] = await Promise.all([
|
||||
providerA(),
|
||||
providerB(),
|
||||
]);
|
||||
] as const);
|
||||
|
||||
const dataA: A[] = resultA;
|
||||
const dataB: B[] = resultB;
|
||||
@@ -23,7 +23,8 @@ async function countEverything(): Promise<number> {
|
||||
return dataA.length + dataB.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [correctOrderOfPromiseMethod.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
|
||||
@@ -43,7 +43,7 @@ async function countEverything(): Promise<number> {
|
||||
providerB(),
|
||||
>providerB : Symbol(providerB, Decl(correctOrderOfPromiseMethod.ts, 11, 9))
|
||||
|
||||
]);
|
||||
] as const);
|
||||
|
||||
const dataA: A[] = resultA;
|
||||
>dataA : Symbol(dataA, Decl(correctOrderOfPromiseMethod.ts, 18, 9))
|
||||
@@ -69,3 +69,4 @@ async function countEverything(): Promise<number> {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,13 @@ async function countEverything(): Promise<number> {
|
||||
const [resultA, resultB] = await Promise.all([
|
||||
>resultA : A[]
|
||||
>resultB : B[]
|
||||
>await Promise.all([ providerA(), providerB(), ]) : [A[], B[]]
|
||||
>Promise.all([ providerA(), providerB(), ]) : Promise<[A[], B[]]>
|
||||
>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[]>; }
|
||||
>await Promise.all([ providerA(), providerB(), ] as const) : [A[], B[]]
|
||||
>Promise.all([ providerA(), providerB(), ] as const) : Promise<[A[], B[]]>
|
||||
>Promise.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (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[]>; }
|
||||
>[ providerA(), providerB(), ] : [Promise<A[]>, Promise<B[]>]
|
||||
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>; }
|
||||
>[ providerA(), providerB(), ] as const : readonly [Promise<A[]>, Promise<B[]>]
|
||||
>[ providerA(), providerB(), ] : readonly [Promise<A[]>, Promise<B[]>]
|
||||
|
||||
providerA(),
|
||||
>providerA() : Promise<A[]>
|
||||
@@ -43,7 +44,7 @@ async function countEverything(): Promise<number> {
|
||||
>providerB() : Promise<B[]>
|
||||
>providerB : () => Promise<B[]>
|
||||
|
||||
]);
|
||||
] as const);
|
||||
|
||||
const dataA: A[] = resultA;
|
||||
>dataA : A[]
|
||||
@@ -70,3 +71,4 @@ async function countEverything(): Promise<number> {
|
||||
return 0;
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian
|
||||
Type 'A' is not assignable to type 'B'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(43,5): error TS2322: Type 'AList2' is not assignable to type 'BList2'.
|
||||
Types of property 'forEach' are incompatible.
|
||||
Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'.
|
||||
Types of parameters 'cb' and 'cb' are incompatible.
|
||||
Type 'void' is not assignable to type 'boolean'.
|
||||
Types of parameters 'cb' and 'cb' are incompatible.
|
||||
Type 'void' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(56,5): error TS2322: Type 'AList3' is not assignable to type 'BList3'.
|
||||
Types of property 'forEach' are incompatible.
|
||||
Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'.
|
||||
@@ -86,9 +85,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian
|
||||
~
|
||||
!!! error TS2322: Type 'AList2' is not assignable to type 'BList2'.
|
||||
!!! error TS2322: Types of property 'forEach' are incompatible.
|
||||
!!! error TS2322: Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'.
|
||||
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
|
||||
!!! error TS2322: Type 'void' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
|
||||
!!! error TS2322: Type 'void' is not assignable to type 'boolean'.
|
||||
}
|
||||
|
||||
interface AList3 {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I<C>'.
|
||||
Types of property 'm' are incompatible.
|
||||
Type '() => void' is not assignable to type '() => C'.
|
||||
Type 'void' is not assignable to type 'C'.
|
||||
The types returned by 'm()' are incompatible between these types.
|
||||
Type 'void' is not assignable to type 'C'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/decoratorCallGeneric.ts (1 errors) ====
|
||||
@@ -14,9 +13,8 @@ tests/cases/conformance/decorators/decoratorCallGeneric.ts(7,2): error TS2345: A
|
||||
@dec
|
||||
~~~
|
||||
!!! error TS2345: Argument of type 'typeof C' is not assignable to parameter of type 'I<C>'.
|
||||
!!! error TS2345: Types of property 'm' are incompatible.
|
||||
!!! error TS2345: Type '() => void' is not assignable to type '() => C'.
|
||||
!!! error TS2345: Type 'void' is not assignable to type 'C'.
|
||||
!!! error TS2345: The types returned by 'm()' are incompatible between these types.
|
||||
!!! error TS2345: Type 'void' is not assignable to type 'C'.
|
||||
class C {
|
||||
_brand: any;
|
||||
static m() {}
|
||||
|
||||
+6
-10
@@ -1,10 +1,8 @@
|
||||
tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(21,33): error TS2322: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'.
|
||||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'.
|
||||
tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34): error TS2326: Types of property 'icon' are incompatible.
|
||||
Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp<ITestProps>'.
|
||||
Types of property 'props' are incompatible.
|
||||
Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'.
|
||||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'.
|
||||
tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34): error TS2200: The types of 'icon.props' are incompatible between these types.
|
||||
Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'.
|
||||
Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts (2 errors) ====
|
||||
@@ -40,9 +38,7 @@ tests/cases/compiler/deepExcessPropertyCheckingWhenTargetIsIntersection.ts(27,34
|
||||
|
||||
TestComponent2({icon: { props: { INVALID_PROP_NAME: 'share', ariaLabel: 'test label' } }});
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2326: Types of property 'icon' are incompatible.
|
||||
!!! error TS2326: Type '{ props: { INVALID_PROP_NAME: string; ariaLabel: string; }; }' is not assignable to type 'NestedProp<ITestProps>'.
|
||||
!!! error TS2326: Types of property 'props' are incompatible.
|
||||
!!! error TS2326: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'.
|
||||
!!! error TS2326: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'.
|
||||
!!! error TS2200: The types of 'icon.props' are incompatible between these types.
|
||||
!!! error TS2200: Type '{ INVALID_PROP_NAME: string; ariaLabel: string; }' is not assignable to type 'ITestProps'.
|
||||
!!! error TS2200: Object literal may only specify known properties, and 'INVALID_PROP_NAME' does not exist in type 'ITestProps'.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts(3,1): error TS2322: Type '{ a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }'.
|
||||
The types of 'a.b.c.d.e.f().g' are incompatible between these types.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts(15,1): error TS2322: Type '{ a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }'.
|
||||
The types of '(new a.b.c.d.e.f()).g' are incompatible between these types.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts (2 errors) ====
|
||||
let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } };
|
||||
let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } };
|
||||
x = y;
|
||||
~
|
||||
!!! error TS2322: Type '{ a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }'.
|
||||
!!! error TS2322: The types of 'a.b.c.d.e.f().g' are incompatible between these types.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
class Ctor1 {
|
||||
g = "ok"
|
||||
}
|
||||
|
||||
class Ctor2 {
|
||||
g = 12;
|
||||
}
|
||||
|
||||
let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } };
|
||||
let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } };
|
||||
x2 = y2;
|
||||
~~
|
||||
!!! error TS2322: Type '{ a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }'.
|
||||
!!! error TS2322: The types of '(new a.b.c.d.e.f()).g' are incompatible between these types.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [deeplyNestedAssignabilityErrorsCombined.ts]
|
||||
let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } };
|
||||
let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } };
|
||||
x = y;
|
||||
|
||||
class Ctor1 {
|
||||
g = "ok"
|
||||
}
|
||||
|
||||
class Ctor2 {
|
||||
g = 12;
|
||||
}
|
||||
|
||||
let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } };
|
||||
let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } };
|
||||
x2 = y2;
|
||||
|
||||
//// [deeplyNestedAssignabilityErrorsCombined.js]
|
||||
var x = { a: { b: { c: { d: { e: { f: function () { return { g: "hello" }; } } } } } } };
|
||||
var y = { a: { b: { c: { d: { e: { f: function () { return { g: 12345 }; } } } } } } };
|
||||
x = y;
|
||||
var Ctor1 = /** @class */ (function () {
|
||||
function Ctor1() {
|
||||
this.g = "ok";
|
||||
}
|
||||
return Ctor1;
|
||||
}());
|
||||
var Ctor2 = /** @class */ (function () {
|
||||
function Ctor2() {
|
||||
this.g = 12;
|
||||
}
|
||||
return Ctor2;
|
||||
}());
|
||||
var x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } };
|
||||
var y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } };
|
||||
x2 = y2;
|
||||
@@ -0,0 +1,63 @@
|
||||
=== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts ===
|
||||
let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } };
|
||||
>x : Symbol(x, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 9))
|
||||
>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 14))
|
||||
>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 19))
|
||||
>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 24))
|
||||
>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 29))
|
||||
>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 34))
|
||||
>g : Symbol(g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 49))
|
||||
|
||||
let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } };
|
||||
>y : Symbol(y, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 3))
|
||||
>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 9))
|
||||
>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 14))
|
||||
>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 19))
|
||||
>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 24))
|
||||
>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 29))
|
||||
>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 34))
|
||||
>g : Symbol(g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 49))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 0, 3))
|
||||
>y : Symbol(y, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 1, 3))
|
||||
|
||||
class Ctor1 {
|
||||
>Ctor1 : Symbol(Ctor1, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 2, 6))
|
||||
|
||||
g = "ok"
|
||||
>g : Symbol(Ctor1.g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 4, 13))
|
||||
}
|
||||
|
||||
class Ctor2 {
|
||||
>Ctor2 : Symbol(Ctor2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 6, 1))
|
||||
|
||||
g = 12;
|
||||
>g : Symbol(Ctor2.g, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 8, 13))
|
||||
}
|
||||
|
||||
let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } };
|
||||
>x2 : Symbol(x2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 3))
|
||||
>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 10))
|
||||
>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 15))
|
||||
>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 20))
|
||||
>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 25))
|
||||
>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 30))
|
||||
>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 35))
|
||||
>Ctor1 : Symbol(Ctor1, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 2, 6))
|
||||
|
||||
let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } };
|
||||
>y2 : Symbol(y2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 3))
|
||||
>a : Symbol(a, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 10))
|
||||
>b : Symbol(b, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 15))
|
||||
>c : Symbol(c, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 20))
|
||||
>d : Symbol(d, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 25))
|
||||
>e : Symbol(e, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 30))
|
||||
>f : Symbol(f, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 35))
|
||||
>Ctor2 : Symbol(Ctor2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 6, 1))
|
||||
|
||||
x2 = y2;
|
||||
>x2 : Symbol(x2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 12, 3))
|
||||
>y2 : Symbol(y2, Decl(deeplyNestedAssignabilityErrorsCombined.ts, 13, 3))
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
=== tests/cases/compiler/deeplyNestedAssignabilityErrorsCombined.ts ===
|
||||
let x = { a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } };
|
||||
>x : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }
|
||||
>{ a: { b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } } : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }
|
||||
>a : { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }
|
||||
>{ b: { c: { d: { e: { f() { return { g: "hello" }; } } } } } } : { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }
|
||||
>b : { c: { d: { e: { f(): { g: string; }; }; }; }; }
|
||||
>{ c: { d: { e: { f() { return { g: "hello" }; } } } } } : { c: { d: { e: { f(): { g: string; }; }; }; }; }
|
||||
>c : { d: { e: { f(): { g: string; }; }; }; }
|
||||
>{ d: { e: { f() { return { g: "hello" }; } } } } : { d: { e: { f(): { g: string; }; }; }; }
|
||||
>d : { e: { f(): { g: string; }; }; }
|
||||
>{ e: { f() { return { g: "hello" }; } } } : { e: { f(): { g: string; }; }; }
|
||||
>e : { f(): { g: string; }; }
|
||||
>{ f() { return { g: "hello" }; } } : { f(): { g: string; }; }
|
||||
>f : () => { g: string; }
|
||||
>{ g: "hello" } : { g: string; }
|
||||
>g : string
|
||||
>"hello" : "hello"
|
||||
|
||||
let y = { a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } };
|
||||
>y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }
|
||||
>{ a: { b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } } : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }
|
||||
>a : { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }
|
||||
>{ b: { c: { d: { e: { f() { return { g: 12345 }; } } } } } } : { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }
|
||||
>b : { c: { d: { e: { f(): { g: number; }; }; }; }; }
|
||||
>{ c: { d: { e: { f() { return { g: 12345 }; } } } } } : { c: { d: { e: { f(): { g: number; }; }; }; }; }
|
||||
>c : { d: { e: { f(): { g: number; }; }; }; }
|
||||
>{ d: { e: { f() { return { g: 12345 }; } } } } : { d: { e: { f(): { g: number; }; }; }; }
|
||||
>d : { e: { f(): { g: number; }; }; }
|
||||
>{ e: { f() { return { g: 12345 }; } } } : { e: { f(): { g: number; }; }; }
|
||||
>e : { f(): { g: number; }; }
|
||||
>{ f() { return { g: 12345 }; } } : { f(): { g: number; }; }
|
||||
>f : () => { g: number; }
|
||||
>{ g: 12345 } : { g: number; }
|
||||
>g : number
|
||||
>12345 : 12345
|
||||
|
||||
x = y;
|
||||
>x = y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }
|
||||
>x : { a: { b: { c: { d: { e: { f(): { g: string; }; }; }; }; }; }; }
|
||||
>y : { a: { b: { c: { d: { e: { f(): { g: number; }; }; }; }; }; }; }
|
||||
|
||||
class Ctor1 {
|
||||
>Ctor1 : Ctor1
|
||||
|
||||
g = "ok"
|
||||
>g : string
|
||||
>"ok" : "ok"
|
||||
}
|
||||
|
||||
class Ctor2 {
|
||||
>Ctor2 : Ctor2
|
||||
|
||||
g = 12;
|
||||
>g : number
|
||||
>12 : 12
|
||||
}
|
||||
|
||||
let x2 = { a: { b: { c: { d: { e: { f: Ctor1 } } } } } };
|
||||
>x2 : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }
|
||||
>{ a: { b: { c: { d: { e: { f: Ctor1 } } } } } } : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }
|
||||
>a : { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }
|
||||
>{ b: { c: { d: { e: { f: Ctor1 } } } } } : { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }
|
||||
>b : { c: { d: { e: { f: typeof Ctor1; }; }; }; }
|
||||
>{ c: { d: { e: { f: Ctor1 } } } } : { c: { d: { e: { f: typeof Ctor1; }; }; }; }
|
||||
>c : { d: { e: { f: typeof Ctor1; }; }; }
|
||||
>{ d: { e: { f: Ctor1 } } } : { d: { e: { f: typeof Ctor1; }; }; }
|
||||
>d : { e: { f: typeof Ctor1; }; }
|
||||
>{ e: { f: Ctor1 } } : { e: { f: typeof Ctor1; }; }
|
||||
>e : { f: typeof Ctor1; }
|
||||
>{ f: Ctor1 } : { f: typeof Ctor1; }
|
||||
>f : typeof Ctor1
|
||||
>Ctor1 : typeof Ctor1
|
||||
|
||||
let y2 = { a: { b: { c: { d: { e: { f: Ctor2 } } } } } };
|
||||
>y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }
|
||||
>{ a: { b: { c: { d: { e: { f: Ctor2 } } } } } } : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }
|
||||
>a : { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }
|
||||
>{ b: { c: { d: { e: { f: Ctor2 } } } } } : { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }
|
||||
>b : { c: { d: { e: { f: typeof Ctor2; }; }; }; }
|
||||
>{ c: { d: { e: { f: Ctor2 } } } } : { c: { d: { e: { f: typeof Ctor2; }; }; }; }
|
||||
>c : { d: { e: { f: typeof Ctor2; }; }; }
|
||||
>{ d: { e: { f: Ctor2 } } } : { d: { e: { f: typeof Ctor2; }; }; }
|
||||
>d : { e: { f: typeof Ctor2; }; }
|
||||
>{ e: { f: Ctor2 } } : { e: { f: typeof Ctor2; }; }
|
||||
>e : { f: typeof Ctor2; }
|
||||
>{ f: Ctor2 } : { f: typeof Ctor2; }
|
||||
>f : typeof Ctor2
|
||||
>Ctor2 : typeof Ctor2
|
||||
|
||||
x2 = y2;
|
||||
>x2 = y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }
|
||||
>x2 : { a: { b: { c: { d: { e: { f: typeof Ctor1; }; }; }; }; }; }
|
||||
>y2 : { a: { b: { c: { d: { e: { f: typeof Ctor2; }; }; }; }; }; }
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
Exit Code: 1
|
||||
Standard output:
|
||||
@uifabric/codepen-loader: yarn run vX.X.X
|
||||
@uifabric/codepen-loader: $ just-scripts build --production --lint
|
||||
@uifabric/codepen-loader: [XX:XX:XX XM] ■ Removing [lib, temp, dist, coverage, lib-commonjs]
|
||||
@uifabric/codepen-loader: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/codepen-loader/tsconfig.json
|
||||
@uifabric/codepen-loader: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --module commonjs --outDir "./lib" --project "/office-ui-fabric-react/packages/codepen-loader/tsconfig.json"
|
||||
@uifabric/codepen-loader: [XX:XX:XX XM] ■ Running Jest
|
||||
@uifabric/codepen-loader: [XX:XX:XX XM] ■ /usr/local/bin/node "/office-ui-fabric-react/node_modules/jest/bin/jest.js" --config "/office-ui-fabric-react/packages/codepen-loader/jest.config.js" --passWithNoTests --colors --forceExit
|
||||
@uifabric/codepen-loader: PASS src/__tests__/codepenTransform.test.ts
|
||||
@uifabric/codepen-loader: Done in ?s.
|
||||
@uifabric/build: yarn run vX.X.X
|
||||
@uifabric/build: $ node ./just-scripts.js no-op --production --lint
|
||||
@uifabric/build: Done in ?s.
|
||||
@@ -36,9 +27,11 @@ Standard output:
|
||||
@uifabric/migration: Done in ?s.
|
||||
@uifabric/monaco-editor: yarn run vX.X.X
|
||||
@uifabric/monaco-editor: $ just-scripts build --production --lint
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Removing [esm, lib]
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Removing [esm, lib, lib-commonjs]
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib --module esnext --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json"
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json
|
||||
@uifabric/monaco-editor: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --inlineSources --sourceRoot "../src" --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json"
|
||||
@uifabric/monaco-editor: Done in ?s.
|
||||
@uifabric/set-version: yarn run vX.X.X
|
||||
@uifabric/set-version: $ just-scripts build --production --lint
|
||||
@@ -91,6 +84,7 @@ Standard output:
|
||||
@uifabric/merge-styles: PASS src/extractStyleParts.test.ts
|
||||
@uifabric/merge-styles: PASS src/server.test.ts
|
||||
@uifabric/merge-styles: PASS src/concatStyleSetsWithProps.test.ts
|
||||
@uifabric/merge-styles: PASS src/fontFace.test.ts
|
||||
@uifabric/merge-styles: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/merge-styles/lib/index.d.ts'
|
||||
@uifabric/merge-styles: Done in ?s.
|
||||
@uifabric/jest-serializer-merge-styles: yarn run vX.X.X
|
||||
@@ -134,9 +128,9 @@ Standard output:
|
||||
@uifabric/utilities: PASS src/warn/warnControlledUsage.test.ts
|
||||
@uifabric/utilities: PASS src/focus.test.tsx
|
||||
@uifabric/utilities: PASS src/styled.test.tsx
|
||||
@uifabric/utilities: PASS src/customizations/Customizer.test.tsx
|
||||
@uifabric/utilities: PASS src/EventGroup.test.ts
|
||||
@uifabric/utilities: PASS src/array.test.ts
|
||||
@uifabric/utilities: PASS src/customizations/Customizer.test.tsx
|
||||
@uifabric/utilities: PASS src/math.test.ts
|
||||
@uifabric/utilities: PASS src/warn/warn.test.ts
|
||||
@uifabric/utilities: PASS src/dom/dom.test.ts
|
||||
@@ -206,7 +200,6 @@ Standard output:
|
||||
@uifabric/styling: PASS src/styles/theme.test.ts
|
||||
@uifabric/styling: PASS src/styles/scheme.test.ts
|
||||
@uifabric/styling: PASS src/styles/getGlobalClassNames.test.ts
|
||||
@uifabric/styling: PASS src/utilities/icons.test.ts
|
||||
@uifabric/styling: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/styling/lib/index.d.ts'
|
||||
@uifabric/styling: Done in ?s.
|
||||
@uifabric/file-type-icons: yarn run vX.X.X
|
||||
@@ -249,11 +242,7 @@ Standard output:
|
||||
Standard error:
|
||||
info cli using local version of lerna
|
||||
lerna notice cli vX.X.X
|
||||
lerna info Executing command in 43 packages: "yarn run build --production --lint"
|
||||
@uifabric/codepen-loader: ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
||||
@uifabric/codepen-loader: Force exiting Jest
|
||||
@uifabric/codepen-loader:
|
||||
@uifabric/codepen-loader: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
|
||||
lerna info Executing command in 42 packages: "yarn run build --production --lint"
|
||||
@uifabric/example-data: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect
|
||||
@uifabric/set-version: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect
|
||||
@uifabric/merge-styles: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(4,1): error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'.
|
||||
Types of property 'bar' are incompatible.
|
||||
Type 'number | undefined' is not assignable to type 'string | null'.
|
||||
Type 'undefined' is not assignable to type 'string | null'.
|
||||
The types of 'foo.bar' are incompatible between these types.
|
||||
Type 'number | undefined' is not assignable to type 'string | null'.
|
||||
Type 'undefined' is not assignable to type 'string | null'.
|
||||
tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322: Type '{ foo: { bar: string | null; } | undefined; } | null | undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'.
|
||||
Type 'undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'.
|
||||
|
||||
@@ -15,11 +13,9 @@ tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322:
|
||||
x = y;
|
||||
~
|
||||
!!! error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'.
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
!!! error TS2322: Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'.
|
||||
!!! error TS2322: Types of property 'bar' are incompatible.
|
||||
!!! error TS2322: Type 'number | undefined' is not assignable to type 'string | null'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'.
|
||||
!!! error TS2322: The types of 'foo.bar' are incompatible between these types.
|
||||
!!! error TS2322: Type 'number | undefined' is not assignable to type 'string | null'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'.
|
||||
|
||||
y = x;
|
||||
~
|
||||
|
||||
@@ -17,9 +17,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(48,32): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(50,5): error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
|
||||
Types of property 'A' are incompatible.
|
||||
Type 'typeof N.A' is not assignable to type 'typeof M.A'.
|
||||
Property 'name' is missing in type 'N.A' but required in type 'M.A'.
|
||||
The types returned by 'new A()' are incompatible between these types.
|
||||
Property 'name' is missing in type 'N.A' but required in type 'M.A'.
|
||||
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(51,5): error TS2322: Type 'N.A' is not assignable to type 'M.A'.
|
||||
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(52,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: number) => string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
@@ -112,9 +111,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd
|
||||
var aModule: typeof M = N;
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
|
||||
!!! error TS2322: Types of property 'A' are incompatible.
|
||||
!!! error TS2322: Type 'typeof N.A' is not assignable to type 'typeof M.A'.
|
||||
!!! error TS2322: Property 'name' is missing in type 'N.A' but required in type 'M.A'.
|
||||
!!! error TS2322: The types returned by 'new A()' are incompatible between these types.
|
||||
!!! error TS2322: Property 'name' is missing in type 'N.A' but required in type 'M.A'.
|
||||
!!! related TS2728 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:20:9: 'name' is declared here.
|
||||
var aClassInModule: M.A = new N.A();
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
@@ -44,4 +44,18 @@ tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts(35,32): error TS7030: Not
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function foo6(bar: "a", a: boolean, b: boolean): number {
|
||||
if (a) {
|
||||
switch (bar) {
|
||||
case "a": return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (b) {
|
||||
case true: return -1;
|
||||
case false: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,20 @@ function foo5(bar: "a" | "b"): number {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function foo6(bar: "a", a: boolean, b: boolean): number {
|
||||
if (a) {
|
||||
switch (bar) {
|
||||
case "a": return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (b) {
|
||||
case true: return -1;
|
||||
case false: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [exhaustiveSwitchImplicitReturn.js]
|
||||
@@ -75,3 +89,16 @@ function foo5(bar) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
function foo6(bar, a, b) {
|
||||
if (a) {
|
||||
switch (bar) {
|
||||
case "a": return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (b) {
|
||||
case true: return -1;
|
||||
case false: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,3 +69,28 @@ function foo5(bar: "a" | "b"): number {
|
||||
}
|
||||
}
|
||||
|
||||
function foo6(bar: "a", a: boolean, b: boolean): number {
|
||||
>foo6 : Symbol(foo6, Decl(exhaustiveSwitchImplicitReturn.ts, 39, 1))
|
||||
>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 14))
|
||||
>a : Symbol(a, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 23))
|
||||
>b : Symbol(b, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 35))
|
||||
|
||||
if (a) {
|
||||
>a : Symbol(a, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 23))
|
||||
|
||||
switch (bar) {
|
||||
>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 14))
|
||||
|
||||
case "a": return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (b) {
|
||||
>b : Symbol(b, Decl(exhaustiveSwitchImplicitReturn.ts, 41, 35))
|
||||
|
||||
case true: return -1;
|
||||
case false: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,3 +85,36 @@ function foo5(bar: "a" | "b"): number {
|
||||
}
|
||||
}
|
||||
|
||||
function foo6(bar: "a", a: boolean, b: boolean): number {
|
||||
>foo6 : (bar: "a", a: boolean, b: boolean) => number
|
||||
>bar : "a"
|
||||
>a : boolean
|
||||
>b : boolean
|
||||
|
||||
if (a) {
|
||||
>a : boolean
|
||||
|
||||
switch (bar) {
|
||||
>bar : "a"
|
||||
|
||||
case "a": return 1;
|
||||
>"a" : "a"
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (b) {
|
||||
>b : boolean
|
||||
|
||||
case true: return -1;
|
||||
>true : true
|
||||
>-1 : -1
|
||||
>1 : 1
|
||||
|
||||
case false: return 0;
|
||||
>false : false
|
||||
>0 : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts(7,9): error TS7027: Unreachable code detected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts (1 errors) ====
|
||||
function f1(x: 1 | 2): string {
|
||||
if (!!true) {
|
||||
switch (x) {
|
||||
case 1: return 'a';
|
||||
case 2: return 'b';
|
||||
}
|
||||
x; // Unreachable
|
||||
~~
|
||||
!!! error TS7027: Unreachable code detected.
|
||||
}
|
||||
else {
|
||||
throw 0;
|
||||
}
|
||||
}
|
||||
|
||||
function f2(x: 1 | 2) {
|
||||
let z: number;
|
||||
switch (x) {
|
||||
case 1: z = 10; break;
|
||||
case 2: z = 20; break;
|
||||
}
|
||||
z; // Definitely assigned
|
||||
}
|
||||
|
||||
function f3(x: 1 | 2) {
|
||||
switch (x) {
|
||||
case 1: return 10;
|
||||
case 2: return 20;
|
||||
// Default considered reachable to allow defensive coding
|
||||
default: throw new Error("Bad input");
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #11572
|
||||
|
||||
enum E { A, B }
|
||||
|
||||
function f(e: E): number {
|
||||
switch (e) {
|
||||
case E.A: return 0
|
||||
case E.B: return 1
|
||||
}
|
||||
}
|
||||
|
||||
function g(e: E): number {
|
||||
if (!true)
|
||||
return -1
|
||||
else
|
||||
switch (e) {
|
||||
case E.A: return 0
|
||||
case E.B: return 1
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #12668
|
||||
|
||||
interface Square { kind: "square"; size: number; }
|
||||
|
||||
interface Rectangle { kind: "rectangle"; width: number; height: number; }
|
||||
|
||||
interface Circle { kind: "circle"; radius: number; }
|
||||
|
||||
interface Triangle { kind: "triangle"; side: number; }
|
||||
|
||||
type Shape = Square | Rectangle | Circle | Triangle;
|
||||
|
||||
function area(s: Shape): number {
|
||||
let area;
|
||||
switch (s.kind) {
|
||||
case "square": area = s.size * s.size; break;
|
||||
case "rectangle": area = s.width * s.height; break;
|
||||
case "circle": area = Math.PI * s.radius * s.radius; break;
|
||||
case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break;
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
function areaWrapped(s: Shape): number {
|
||||
let area;
|
||||
area = (() => {
|
||||
switch (s.kind) {
|
||||
case "square": return s.size * s.size;
|
||||
case "rectangle": return s.width * s.height;
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
|
||||
}
|
||||
})();
|
||||
return area;
|
||||
}
|
||||
|
||||
// Repro from #13241
|
||||
|
||||
enum MyEnum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
function thisGivesError(e: MyEnum): string {
|
||||
let s: string;
|
||||
switch (e) {
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function good1(e: MyEnum): string {
|
||||
let s: string;
|
||||
switch (e) {
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
default: s = "it was something else"; break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function good2(e: MyEnum): string {
|
||||
switch (e) {
|
||||
case MyEnum.A: return "it was A";
|
||||
case MyEnum.B: return "it was B";
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #18362
|
||||
|
||||
enum Level {
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
const doSomethingWithLevel = (level: Level) => {
|
||||
let next: Level;
|
||||
switch (level) {
|
||||
case Level.One:
|
||||
next = Level.Two;
|
||||
break;
|
||||
case Level.Two:
|
||||
next = Level.One;
|
||||
break;
|
||||
}
|
||||
return next;
|
||||
};
|
||||
|
||||
// Repro from #20409
|
||||
|
||||
interface Square2 {
|
||||
kind: "square";
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface Circle2 {
|
||||
kind: "circle";
|
||||
radius: number;
|
||||
}
|
||||
|
||||
type Shape2 = Square2 | Circle2;
|
||||
|
||||
function withDefault(s1: Shape2, s2: Shape2): string {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
default:
|
||||
return "never";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function withoutDefault(s1: Shape2, s2: Shape2): string {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #20823
|
||||
|
||||
function test4(value: 1 | 2) {
|
||||
let x: string;
|
||||
switch (value) {
|
||||
case 1: x = "one"; break;
|
||||
case 2: x = "two"; break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,437 @@
|
||||
//// [exhaustiveSwitchStatements1.ts]
|
||||
function f1(x: 1 | 2): string {
|
||||
if (!!true) {
|
||||
switch (x) {
|
||||
case 1: return 'a';
|
||||
case 2: return 'b';
|
||||
}
|
||||
x; // Unreachable
|
||||
}
|
||||
else {
|
||||
throw 0;
|
||||
}
|
||||
}
|
||||
|
||||
function f2(x: 1 | 2) {
|
||||
let z: number;
|
||||
switch (x) {
|
||||
case 1: z = 10; break;
|
||||
case 2: z = 20; break;
|
||||
}
|
||||
z; // Definitely assigned
|
||||
}
|
||||
|
||||
function f3(x: 1 | 2) {
|
||||
switch (x) {
|
||||
case 1: return 10;
|
||||
case 2: return 20;
|
||||
// Default considered reachable to allow defensive coding
|
||||
default: throw new Error("Bad input");
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #11572
|
||||
|
||||
enum E { A, B }
|
||||
|
||||
function f(e: E): number {
|
||||
switch (e) {
|
||||
case E.A: return 0
|
||||
case E.B: return 1
|
||||
}
|
||||
}
|
||||
|
||||
function g(e: E): number {
|
||||
if (!true)
|
||||
return -1
|
||||
else
|
||||
switch (e) {
|
||||
case E.A: return 0
|
||||
case E.B: return 1
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #12668
|
||||
|
||||
interface Square { kind: "square"; size: number; }
|
||||
|
||||
interface Rectangle { kind: "rectangle"; width: number; height: number; }
|
||||
|
||||
interface Circle { kind: "circle"; radius: number; }
|
||||
|
||||
interface Triangle { kind: "triangle"; side: number; }
|
||||
|
||||
type Shape = Square | Rectangle | Circle | Triangle;
|
||||
|
||||
function area(s: Shape): number {
|
||||
let area;
|
||||
switch (s.kind) {
|
||||
case "square": area = s.size * s.size; break;
|
||||
case "rectangle": area = s.width * s.height; break;
|
||||
case "circle": area = Math.PI * s.radius * s.radius; break;
|
||||
case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break;
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
function areaWrapped(s: Shape): number {
|
||||
let area;
|
||||
area = (() => {
|
||||
switch (s.kind) {
|
||||
case "square": return s.size * s.size;
|
||||
case "rectangle": return s.width * s.height;
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
|
||||
}
|
||||
})();
|
||||
return area;
|
||||
}
|
||||
|
||||
// Repro from #13241
|
||||
|
||||
enum MyEnum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
function thisGivesError(e: MyEnum): string {
|
||||
let s: string;
|
||||
switch (e) {
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function good1(e: MyEnum): string {
|
||||
let s: string;
|
||||
switch (e) {
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
default: s = "it was something else"; break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
function good2(e: MyEnum): string {
|
||||
switch (e) {
|
||||
case MyEnum.A: return "it was A";
|
||||
case MyEnum.B: return "it was B";
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #18362
|
||||
|
||||
enum Level {
|
||||
One,
|
||||
Two,
|
||||
}
|
||||
|
||||
const doSomethingWithLevel = (level: Level) => {
|
||||
let next: Level;
|
||||
switch (level) {
|
||||
case Level.One:
|
||||
next = Level.Two;
|
||||
break;
|
||||
case Level.Two:
|
||||
next = Level.One;
|
||||
break;
|
||||
}
|
||||
return next;
|
||||
};
|
||||
|
||||
// Repro from #20409
|
||||
|
||||
interface Square2 {
|
||||
kind: "square";
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface Circle2 {
|
||||
kind: "circle";
|
||||
radius: number;
|
||||
}
|
||||
|
||||
type Shape2 = Square2 | Circle2;
|
||||
|
||||
function withDefault(s1: Shape2, s2: Shape2): string {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
default:
|
||||
return "never";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function withoutDefault(s1: Shape2, s2: Shape2): string {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #20823
|
||||
|
||||
function test4(value: 1 | 2) {
|
||||
let x: string;
|
||||
switch (value) {
|
||||
case 1: x = "one"; break;
|
||||
case 2: x = "two"; break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
//// [exhaustiveSwitchStatements1.js]
|
||||
"use strict";
|
||||
function f1(x) {
|
||||
if (!!true) {
|
||||
switch (x) {
|
||||
case 1: return 'a';
|
||||
case 2: return 'b';
|
||||
}
|
||||
x; // Unreachable
|
||||
}
|
||||
else {
|
||||
throw 0;
|
||||
}
|
||||
}
|
||||
function f2(x) {
|
||||
var z;
|
||||
switch (x) {
|
||||
case 1:
|
||||
z = 10;
|
||||
break;
|
||||
case 2:
|
||||
z = 20;
|
||||
break;
|
||||
}
|
||||
z; // Definitely assigned
|
||||
}
|
||||
function f3(x) {
|
||||
switch (x) {
|
||||
case 1: return 10;
|
||||
case 2: return 20;
|
||||
// Default considered reachable to allow defensive coding
|
||||
default: throw new Error("Bad input");
|
||||
}
|
||||
}
|
||||
// Repro from #11572
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
})(E || (E = {}));
|
||||
function f(e) {
|
||||
switch (e) {
|
||||
case E.A: return 0;
|
||||
case E.B: return 1;
|
||||
}
|
||||
}
|
||||
function g(e) {
|
||||
if (!true)
|
||||
return -1;
|
||||
else
|
||||
switch (e) {
|
||||
case E.A: return 0;
|
||||
case E.B: return 1;
|
||||
}
|
||||
}
|
||||
function area(s) {
|
||||
var area;
|
||||
switch (s.kind) {
|
||||
case "square":
|
||||
area = s.size * s.size;
|
||||
break;
|
||||
case "rectangle":
|
||||
area = s.width * s.height;
|
||||
break;
|
||||
case "circle":
|
||||
area = Math.PI * s.radius * s.radius;
|
||||
break;
|
||||
case "triangle":
|
||||
area = Math.sqrt(3) / 4 * s.side * s.side;
|
||||
break;
|
||||
}
|
||||
return area;
|
||||
}
|
||||
function areaWrapped(s) {
|
||||
var area;
|
||||
area = (function () {
|
||||
switch (s.kind) {
|
||||
case "square": return s.size * s.size;
|
||||
case "rectangle": return s.width * s.height;
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
|
||||
}
|
||||
})();
|
||||
return area;
|
||||
}
|
||||
// Repro from #13241
|
||||
var MyEnum;
|
||||
(function (MyEnum) {
|
||||
MyEnum[MyEnum["A"] = 0] = "A";
|
||||
MyEnum[MyEnum["B"] = 1] = "B";
|
||||
})(MyEnum || (MyEnum = {}));
|
||||
function thisGivesError(e) {
|
||||
var s;
|
||||
switch (e) {
|
||||
case MyEnum.A:
|
||||
s = "it was A";
|
||||
break;
|
||||
case MyEnum.B:
|
||||
s = "it was B";
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
function good1(e) {
|
||||
var s;
|
||||
switch (e) {
|
||||
case MyEnum.A:
|
||||
s = "it was A";
|
||||
break;
|
||||
case MyEnum.B:
|
||||
s = "it was B";
|
||||
break;
|
||||
default:
|
||||
s = "it was something else";
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
function good2(e) {
|
||||
switch (e) {
|
||||
case MyEnum.A: return "it was A";
|
||||
case MyEnum.B: return "it was B";
|
||||
}
|
||||
}
|
||||
// Repro from #18362
|
||||
var Level;
|
||||
(function (Level) {
|
||||
Level[Level["One"] = 0] = "One";
|
||||
Level[Level["Two"] = 1] = "Two";
|
||||
})(Level || (Level = {}));
|
||||
var doSomethingWithLevel = function (level) {
|
||||
var next;
|
||||
switch (level) {
|
||||
case Level.One:
|
||||
next = Level.Two;
|
||||
break;
|
||||
case Level.Two:
|
||||
next = Level.One;
|
||||
break;
|
||||
}
|
||||
return next;
|
||||
};
|
||||
function withDefault(s1, s2) {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
default:
|
||||
return "never";
|
||||
}
|
||||
}
|
||||
}
|
||||
function withoutDefault(s1, s2) {
|
||||
switch (s1.kind) {
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Repro from #20823
|
||||
function test4(value) {
|
||||
var x;
|
||||
switch (value) {
|
||||
case 1:
|
||||
x = "one";
|
||||
break;
|
||||
case 2:
|
||||
x = "two";
|
||||
break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
//// [exhaustiveSwitchStatements1.d.ts]
|
||||
declare function f1(x: 1 | 2): string;
|
||||
declare function f2(x: 1 | 2): void;
|
||||
declare function f3(x: 1 | 2): 10 | 20;
|
||||
declare enum E {
|
||||
A = 0,
|
||||
B = 1
|
||||
}
|
||||
declare function f(e: E): number;
|
||||
declare function g(e: E): number;
|
||||
interface Square {
|
||||
kind: "square";
|
||||
size: number;
|
||||
}
|
||||
interface Rectangle {
|
||||
kind: "rectangle";
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
interface Circle {
|
||||
kind: "circle";
|
||||
radius: number;
|
||||
}
|
||||
interface Triangle {
|
||||
kind: "triangle";
|
||||
side: number;
|
||||
}
|
||||
declare type Shape = Square | Rectangle | Circle | Triangle;
|
||||
declare function area(s: Shape): number;
|
||||
declare function areaWrapped(s: Shape): number;
|
||||
declare enum MyEnum {
|
||||
A = 0,
|
||||
B = 1
|
||||
}
|
||||
declare function thisGivesError(e: MyEnum): string;
|
||||
declare function good1(e: MyEnum): string;
|
||||
declare function good2(e: MyEnum): string;
|
||||
declare enum Level {
|
||||
One = 0,
|
||||
Two = 1
|
||||
}
|
||||
declare const doSomethingWithLevel: (level: Level) => Level;
|
||||
interface Square2 {
|
||||
kind: "square";
|
||||
size: number;
|
||||
}
|
||||
interface Circle2 {
|
||||
kind: "circle";
|
||||
radius: number;
|
||||
}
|
||||
declare type Shape2 = Square2 | Circle2;
|
||||
declare function withDefault(s1: Shape2, s2: Shape2): string;
|
||||
declare function withoutDefault(s1: Shape2, s2: Shape2): string;
|
||||
declare function test4(value: 1 | 2): string;
|
||||
@@ -0,0 +1,503 @@
|
||||
=== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts ===
|
||||
function f1(x: 1 | 2): string {
|
||||
>f1 : Symbol(f1, Decl(exhaustiveSwitchStatements1.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12))
|
||||
|
||||
if (!!true) {
|
||||
switch (x) {
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12))
|
||||
|
||||
case 1: return 'a';
|
||||
case 2: return 'b';
|
||||
}
|
||||
x; // Unreachable
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 0, 12))
|
||||
}
|
||||
else {
|
||||
throw 0;
|
||||
}
|
||||
}
|
||||
|
||||
function f2(x: 1 | 2) {
|
||||
>f2 : Symbol(f2, Decl(exhaustiveSwitchStatements1.ts, 11, 1))
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 13, 12))
|
||||
|
||||
let z: number;
|
||||
>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7))
|
||||
|
||||
switch (x) {
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 13, 12))
|
||||
|
||||
case 1: z = 10; break;
|
||||
>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7))
|
||||
|
||||
case 2: z = 20; break;
|
||||
>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7))
|
||||
}
|
||||
z; // Definitely assigned
|
||||
>z : Symbol(z, Decl(exhaustiveSwitchStatements1.ts, 14, 7))
|
||||
}
|
||||
|
||||
function f3(x: 1 | 2) {
|
||||
>f3 : Symbol(f3, Decl(exhaustiveSwitchStatements1.ts, 20, 1))
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 22, 12))
|
||||
|
||||
switch (x) {
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 22, 12))
|
||||
|
||||
case 1: return 10;
|
||||
case 2: return 20;
|
||||
// Default considered reachable to allow defensive coding
|
||||
default: throw new Error("Bad input");
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #11572
|
||||
|
||||
enum E { A, B }
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8))
|
||||
>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11))
|
||||
|
||||
function f(e: E): number {
|
||||
>f : Symbol(f, Decl(exhaustiveSwitchStatements1.ts, 33, 15))
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 35, 11))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
|
||||
switch (e) {
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 35, 11))
|
||||
|
||||
case E.A: return 0
|
||||
>E.A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8))
|
||||
|
||||
case E.B: return 1
|
||||
>E.B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11))
|
||||
}
|
||||
}
|
||||
|
||||
function g(e: E): number {
|
||||
>g : Symbol(g, Decl(exhaustiveSwitchStatements1.ts, 40, 1))
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 42, 11))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
|
||||
if (!true)
|
||||
return -1
|
||||
else
|
||||
switch (e) {
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 42, 11))
|
||||
|
||||
case E.A: return 0
|
||||
>E.A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
>A : Symbol(E.A, Decl(exhaustiveSwitchStatements1.ts, 33, 8))
|
||||
|
||||
case E.B: return 1
|
||||
>E.B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11))
|
||||
>E : Symbol(E, Decl(exhaustiveSwitchStatements1.ts, 29, 1))
|
||||
>B : Symbol(E.B, Decl(exhaustiveSwitchStatements1.ts, 33, 11))
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #12668
|
||||
|
||||
interface Square { kind: "square"; size: number; }
|
||||
>Square : Symbol(Square, Decl(exhaustiveSwitchStatements1.ts, 50, 1))
|
||||
>kind : Symbol(Square.kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18))
|
||||
>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
|
||||
interface Rectangle { kind: "rectangle"; width: number; height: number; }
|
||||
>Rectangle : Symbol(Rectangle, Decl(exhaustiveSwitchStatements1.ts, 54, 50))
|
||||
>kind : Symbol(Rectangle.kind, Decl(exhaustiveSwitchStatements1.ts, 56, 21))
|
||||
>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40))
|
||||
>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55))
|
||||
|
||||
interface Circle { kind: "circle"; radius: number; }
|
||||
>Circle : Symbol(Circle, Decl(exhaustiveSwitchStatements1.ts, 56, 73))
|
||||
>kind : Symbol(Circle.kind, Decl(exhaustiveSwitchStatements1.ts, 58, 18))
|
||||
>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
|
||||
interface Triangle { kind: "triangle"; side: number; }
|
||||
>Triangle : Symbol(Triangle, Decl(exhaustiveSwitchStatements1.ts, 58, 52))
|
||||
>kind : Symbol(Triangle.kind, Decl(exhaustiveSwitchStatements1.ts, 60, 20))
|
||||
>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
|
||||
type Shape = Square | Rectangle | Circle | Triangle;
|
||||
>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54))
|
||||
>Square : Symbol(Square, Decl(exhaustiveSwitchStatements1.ts, 50, 1))
|
||||
>Rectangle : Symbol(Rectangle, Decl(exhaustiveSwitchStatements1.ts, 54, 50))
|
||||
>Circle : Symbol(Circle, Decl(exhaustiveSwitchStatements1.ts, 56, 73))
|
||||
>Triangle : Symbol(Triangle, Decl(exhaustiveSwitchStatements1.ts, 58, 52))
|
||||
|
||||
function area(s: Shape): number {
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 62, 52))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54))
|
||||
|
||||
let area;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20))
|
||||
|
||||
case "square": area = s.size * s.size; break;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
|
||||
case "rectangle": area = s.width * s.height; break;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
>s.width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40))
|
||||
>s.height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55))
|
||||
|
||||
case "circle": area = Math.PI * s.radius * s.radius; break;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
|
||||
case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --))
|
||||
>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 64, 14))
|
||||
>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
}
|
||||
return area;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 65, 7))
|
||||
}
|
||||
|
||||
function areaWrapped(s: Shape): number {
|
||||
>areaWrapped : Symbol(areaWrapped, Decl(exhaustiveSwitchStatements1.ts, 73, 1))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>Shape : Symbol(Shape, Decl(exhaustiveSwitchStatements1.ts, 60, 54))
|
||||
|
||||
let area;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7))
|
||||
|
||||
area = (() => {
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7))
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 54, 18), Decl(exhaustiveSwitchStatements1.ts, 56, 21), Decl(exhaustiveSwitchStatements1.ts, 58, 18), Decl(exhaustiveSwitchStatements1.ts, 60, 20))
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s.size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>size : Symbol(Square.size, Decl(exhaustiveSwitchStatements1.ts, 54, 34))
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>s.width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>width : Symbol(Rectangle.width, Decl(exhaustiveSwitchStatements1.ts, 56, 40))
|
||||
>s.height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>height : Symbol(Rectangle.height, Decl(exhaustiveSwitchStatements1.ts, 56, 55))
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.es5.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s.radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>radius : Symbol(Circle.radius, Decl(exhaustiveSwitchStatements1.ts, 58, 34))
|
||||
|
||||
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
|
||||
>Math.sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>sqrt : Symbol(Math.sqrt, Decl(lib.es5.d.ts, --, --))
|
||||
>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s.side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 75, 21))
|
||||
>side : Symbol(Triangle.side, Decl(exhaustiveSwitchStatements1.ts, 60, 38))
|
||||
}
|
||||
})();
|
||||
return area;
|
||||
>area : Symbol(area, Decl(exhaustiveSwitchStatements1.ts, 76, 7))
|
||||
}
|
||||
|
||||
// Repro from #13241
|
||||
|
||||
enum MyEnum {
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
|
||||
A,
|
||||
>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
|
||||
B
|
||||
>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
}
|
||||
|
||||
function thisGivesError(e: MyEnum): string {
|
||||
>thisGivesError : Symbol(thisGivesError, Decl(exhaustiveSwitchStatements1.ts, 93, 1))
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 95, 24))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
|
||||
let s: string;
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4))
|
||||
|
||||
switch (e) {
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 95, 24))
|
||||
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4))
|
||||
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4))
|
||||
}
|
||||
return s;
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 96, 4))
|
||||
}
|
||||
|
||||
function good1(e: MyEnum): string {
|
||||
>good1 : Symbol(good1, Decl(exhaustiveSwitchStatements1.ts, 102, 1))
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 104, 15))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
|
||||
let s: string;
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4))
|
||||
|
||||
switch (e) {
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 104, 15))
|
||||
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4))
|
||||
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4))
|
||||
|
||||
default: s = "it was something else"; break;
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4))
|
||||
}
|
||||
return s;
|
||||
>s : Symbol(s, Decl(exhaustiveSwitchStatements1.ts, 105, 4))
|
||||
}
|
||||
|
||||
function good2(e: MyEnum): string {
|
||||
>good2 : Symbol(good2, Decl(exhaustiveSwitchStatements1.ts, 112, 1))
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 114, 15))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
|
||||
switch (e) {
|
||||
>e : Symbol(e, Decl(exhaustiveSwitchStatements1.ts, 114, 15))
|
||||
|
||||
case MyEnum.A: return "it was A";
|
||||
>MyEnum.A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>A : Symbol(MyEnum.A, Decl(exhaustiveSwitchStatements1.ts, 90, 13))
|
||||
|
||||
case MyEnum.B: return "it was B";
|
||||
>MyEnum.B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
>MyEnum : Symbol(MyEnum, Decl(exhaustiveSwitchStatements1.ts, 86, 1))
|
||||
>B : Symbol(MyEnum.B, Decl(exhaustiveSwitchStatements1.ts, 91, 3))
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #18362
|
||||
|
||||
enum Level {
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
|
||||
One,
|
||||
>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12))
|
||||
|
||||
Two,
|
||||
>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6))
|
||||
}
|
||||
|
||||
const doSomethingWithLevel = (level: Level) => {
|
||||
>doSomethingWithLevel : Symbol(doSomethingWithLevel, Decl(exhaustiveSwitchStatements1.ts, 128, 5))
|
||||
>level : Symbol(level, Decl(exhaustiveSwitchStatements1.ts, 128, 30))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
|
||||
let next: Level;
|
||||
>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
|
||||
switch (level) {
|
||||
>level : Symbol(level, Decl(exhaustiveSwitchStatements1.ts, 128, 30))
|
||||
|
||||
case Level.One:
|
||||
>Level.One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12))
|
||||
|
||||
next = Level.Two;
|
||||
>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5))
|
||||
>Level.Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6))
|
||||
|
||||
break;
|
||||
case Level.Two:
|
||||
>Level.Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
>Two : Symbol(Level.Two, Decl(exhaustiveSwitchStatements1.ts, 124, 6))
|
||||
|
||||
next = Level.One;
|
||||
>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5))
|
||||
>Level.One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12))
|
||||
>Level : Symbol(Level, Decl(exhaustiveSwitchStatements1.ts, 119, 1))
|
||||
>One : Symbol(Level.One, Decl(exhaustiveSwitchStatements1.ts, 123, 12))
|
||||
|
||||
break;
|
||||
}
|
||||
return next;
|
||||
>next : Symbol(next, Decl(exhaustiveSwitchStatements1.ts, 129, 5))
|
||||
|
||||
};
|
||||
|
||||
// Repro from #20409
|
||||
|
||||
interface Square2 {
|
||||
>Square2 : Symbol(Square2, Decl(exhaustiveSwitchStatements1.ts, 139, 2))
|
||||
|
||||
kind: "square";
|
||||
>kind : Symbol(Square2.kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19))
|
||||
|
||||
size: number;
|
||||
>size : Symbol(Square2.size, Decl(exhaustiveSwitchStatements1.ts, 144, 19))
|
||||
}
|
||||
|
||||
interface Circle2 {
|
||||
>Circle2 : Symbol(Circle2, Decl(exhaustiveSwitchStatements1.ts, 146, 1))
|
||||
|
||||
kind: "circle";
|
||||
>kind : Symbol(Circle2.kind, Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
|
||||
radius: number;
|
||||
>radius : Symbol(Circle2.radius, Decl(exhaustiveSwitchStatements1.ts, 149, 19))
|
||||
}
|
||||
|
||||
type Shape2 = Square2 | Circle2;
|
||||
>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1))
|
||||
>Square2 : Symbol(Square2, Decl(exhaustiveSwitchStatements1.ts, 139, 2))
|
||||
>Circle2 : Symbol(Circle2, Decl(exhaustiveSwitchStatements1.ts, 146, 1))
|
||||
|
||||
function withDefault(s1: Shape2, s2: Shape2): string {
|
||||
>withDefault : Symbol(withDefault, Decl(exhaustiveSwitchStatements1.ts, 153, 32))
|
||||
>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 155, 21))
|
||||
>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1))
|
||||
>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 155, 32))
|
||||
>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1))
|
||||
|
||||
switch (s1.kind) {
|
||||
>s1.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 155, 21))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
>s2.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 155, 32))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
default:
|
||||
return "never";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function withoutDefault(s1: Shape2, s2: Shape2): string {
|
||||
>withoutDefault : Symbol(withoutDefault, Decl(exhaustiveSwitchStatements1.ts, 169, 1))
|
||||
>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 171, 24))
|
||||
>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1))
|
||||
>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 171, 35))
|
||||
>Shape2 : Symbol(Shape2, Decl(exhaustiveSwitchStatements1.ts, 151, 1))
|
||||
|
||||
switch (s1.kind) {
|
||||
>s1.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
>s1 : Symbol(s1, Decl(exhaustiveSwitchStatements1.ts, 171, 24))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
|
||||
case "square":
|
||||
return "1";
|
||||
case "circle":
|
||||
switch (s2.kind) {
|
||||
>s2.kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
>s2 : Symbol(s2, Decl(exhaustiveSwitchStatements1.ts, 171, 35))
|
||||
>kind : Symbol(kind, Decl(exhaustiveSwitchStatements1.ts, 143, 19), Decl(exhaustiveSwitchStatements1.ts, 148, 19))
|
||||
|
||||
case "square":
|
||||
return "2";
|
||||
case "circle":
|
||||
return "3";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #20823
|
||||
|
||||
function test4(value: 1 | 2) {
|
||||
>test4 : Symbol(test4, Decl(exhaustiveSwitchStatements1.ts, 183, 1))
|
||||
>value : Symbol(value, Decl(exhaustiveSwitchStatements1.ts, 187, 15))
|
||||
|
||||
let x: string;
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7))
|
||||
|
||||
switch (value) {
|
||||
>value : Symbol(value, Decl(exhaustiveSwitchStatements1.ts, 187, 15))
|
||||
|
||||
case 1: x = "one"; break;
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7))
|
||||
|
||||
case 2: x = "two"; break;
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7))
|
||||
}
|
||||
return x;
|
||||
>x : Symbol(x, Decl(exhaustiveSwitchStatements1.ts, 188, 7))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,595 @@
|
||||
=== tests/cases/conformance/controlFlow/exhaustiveSwitchStatements1.ts ===
|
||||
function f1(x: 1 | 2): string {
|
||||
>f1 : (x: 1 | 2) => string
|
||||
>x : 1 | 2
|
||||
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
switch (x) {
|
||||
>x : 1 | 2
|
||||
|
||||
case 1: return 'a';
|
||||
>1 : 1
|
||||
>'a' : "a"
|
||||
|
||||
case 2: return 'b';
|
||||
>2 : 2
|
||||
>'b' : "b"
|
||||
}
|
||||
x; // Unreachable
|
||||
>x : never
|
||||
}
|
||||
else {
|
||||
throw 0;
|
||||
>0 : 0
|
||||
}
|
||||
}
|
||||
|
||||
function f2(x: 1 | 2) {
|
||||
>f2 : (x: 1 | 2) => void
|
||||
>x : 1 | 2
|
||||
|
||||
let z: number;
|
||||
>z : number
|
||||
|
||||
switch (x) {
|
||||
>x : 1 | 2
|
||||
|
||||
case 1: z = 10; break;
|
||||
>1 : 1
|
||||
>z = 10 : 10
|
||||
>z : number
|
||||
>10 : 10
|
||||
|
||||
case 2: z = 20; break;
|
||||
>2 : 2
|
||||
>z = 20 : 20
|
||||
>z : number
|
||||
>20 : 20
|
||||
}
|
||||
z; // Definitely assigned
|
||||
>z : number
|
||||
}
|
||||
|
||||
function f3(x: 1 | 2) {
|
||||
>f3 : (x: 1 | 2) => 10 | 20
|
||||
>x : 1 | 2
|
||||
|
||||
switch (x) {
|
||||
>x : 1 | 2
|
||||
|
||||
case 1: return 10;
|
||||
>1 : 1
|
||||
>10 : 10
|
||||
|
||||
case 2: return 20;
|
||||
>2 : 2
|
||||
>20 : 20
|
||||
|
||||
// Default considered reachable to allow defensive coding
|
||||
default: throw new Error("Bad input");
|
||||
>new Error("Bad input") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"Bad input" : "Bad input"
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #11572
|
||||
|
||||
enum E { A, B }
|
||||
>E : E
|
||||
>A : E.A
|
||||
>B : E.B
|
||||
|
||||
function f(e: E): number {
|
||||
>f : (e: E) => number
|
||||
>e : E
|
||||
|
||||
switch (e) {
|
||||
>e : E
|
||||
|
||||
case E.A: return 0
|
||||
>E.A : E.A
|
||||
>E : typeof E
|
||||
>A : E.A
|
||||
>0 : 0
|
||||
|
||||
case E.B: return 1
|
||||
>E.B : E.B
|
||||
>E : typeof E
|
||||
>B : E.B
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
function g(e: E): number {
|
||||
>g : (e: E) => number
|
||||
>e : E
|
||||
|
||||
if (!true)
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
return -1
|
||||
>-1 : -1
|
||||
>1 : 1
|
||||
|
||||
else
|
||||
switch (e) {
|
||||
>e : E
|
||||
|
||||
case E.A: return 0
|
||||
>E.A : E.A
|
||||
>E : typeof E
|
||||
>A : E.A
|
||||
>0 : 0
|
||||
|
||||
case E.B: return 1
|
||||
>E.B : E.B
|
||||
>E : typeof E
|
||||
>B : E.B
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #12668
|
||||
|
||||
interface Square { kind: "square"; size: number; }
|
||||
>kind : "square"
|
||||
>size : number
|
||||
|
||||
interface Rectangle { kind: "rectangle"; width: number; height: number; }
|
||||
>kind : "rectangle"
|
||||
>width : number
|
||||
>height : number
|
||||
|
||||
interface Circle { kind: "circle"; radius: number; }
|
||||
>kind : "circle"
|
||||
>radius : number
|
||||
|
||||
interface Triangle { kind: "triangle"; side: number; }
|
||||
>kind : "triangle"
|
||||
>side : number
|
||||
|
||||
type Shape = Square | Rectangle | Circle | Triangle;
|
||||
>Shape : Shape
|
||||
|
||||
function area(s: Shape): number {
|
||||
>area : (s: Shape) => number
|
||||
>s : Shape
|
||||
|
||||
let area;
|
||||
>area : any
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : "square" | "rectangle" | "circle" | "triangle"
|
||||
>s : Shape
|
||||
>kind : "square" | "rectangle" | "circle" | "triangle"
|
||||
|
||||
case "square": area = s.size * s.size; break;
|
||||
>"square" : "square"
|
||||
>area = s.size * s.size : number
|
||||
>area : any
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
|
||||
case "rectangle": area = s.width * s.height; break;
|
||||
>"rectangle" : "rectangle"
|
||||
>area = s.width * s.height : number
|
||||
>area : any
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
|
||||
case "circle": area = Math.PI * s.radius * s.radius; break;
|
||||
>"circle" : "circle"
|
||||
>area = Math.PI * s.radius * s.radius : number
|
||||
>area : any
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
|
||||
case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break;
|
||||
>"triangle" : "triangle"
|
||||
>area = Math.sqrt(3) / 4 * s.side * s.side : number
|
||||
>area : any
|
||||
>Math.sqrt(3) / 4 * s.side * s.side : number
|
||||
>Math.sqrt(3) / 4 * s.side : number
|
||||
>Math.sqrt(3) / 4 : number
|
||||
>Math.sqrt(3) : number
|
||||
>Math.sqrt : (x: number) => number
|
||||
>Math : Math
|
||||
>sqrt : (x: number) => number
|
||||
>3 : 3
|
||||
>4 : 4
|
||||
>s.side : number
|
||||
>s : Triangle
|
||||
>side : number
|
||||
>s.side : number
|
||||
>s : Triangle
|
||||
>side : number
|
||||
}
|
||||
return area;
|
||||
>area : number
|
||||
}
|
||||
|
||||
function areaWrapped(s: Shape): number {
|
||||
>areaWrapped : (s: Shape) => number
|
||||
>s : Shape
|
||||
|
||||
let area;
|
||||
>area : any
|
||||
|
||||
area = (() => {
|
||||
>area = (() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } })() : number
|
||||
>area : any
|
||||
>(() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } })() : number
|
||||
>(() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } }) : () => number
|
||||
>() => { switch (s.kind) { case "square": return s.size * s.size; case "rectangle": return s.width * s.height; case "circle": return Math.PI * s.radius * s.radius; case "triangle": return Math.sqrt(3) / 4 * s.side * s.side; } } : () => number
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : "square" | "rectangle" | "circle" | "triangle"
|
||||
>s : Shape
|
||||
>kind : "square" | "rectangle" | "circle" | "triangle"
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>"square" : "square"
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>"rectangle" : "rectangle"
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>"circle" : "circle"
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
|
||||
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
|
||||
>"triangle" : "triangle"
|
||||
>Math.sqrt(3) / 4 * s.side * s.side : number
|
||||
>Math.sqrt(3) / 4 * s.side : number
|
||||
>Math.sqrt(3) / 4 : number
|
||||
>Math.sqrt(3) : number
|
||||
>Math.sqrt : (x: number) => number
|
||||
>Math : Math
|
||||
>sqrt : (x: number) => number
|
||||
>3 : 3
|
||||
>4 : 4
|
||||
>s.side : number
|
||||
>s : Triangle
|
||||
>side : number
|
||||
>s.side : number
|
||||
>s : Triangle
|
||||
>side : number
|
||||
}
|
||||
})();
|
||||
return area;
|
||||
>area : number
|
||||
}
|
||||
|
||||
// Repro from #13241
|
||||
|
||||
enum MyEnum {
|
||||
>MyEnum : MyEnum
|
||||
|
||||
A,
|
||||
>A : MyEnum.A
|
||||
|
||||
B
|
||||
>B : MyEnum.B
|
||||
}
|
||||
|
||||
function thisGivesError(e: MyEnum): string {
|
||||
>thisGivesError : (e: MyEnum) => string
|
||||
>e : MyEnum
|
||||
|
||||
let s: string;
|
||||
>s : string
|
||||
|
||||
switch (e) {
|
||||
>e : MyEnum
|
||||
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
>MyEnum.A : MyEnum.A
|
||||
>MyEnum : typeof MyEnum
|
||||
>A : MyEnum.A
|
||||
>s = "it was A" : "it was A"
|
||||
>s : string
|
||||
>"it was A" : "it was A"
|
||||
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
>MyEnum.B : MyEnum.B
|
||||
>MyEnum : typeof MyEnum
|
||||
>B : MyEnum.B
|
||||
>s = "it was B" : "it was B"
|
||||
>s : string
|
||||
>"it was B" : "it was B"
|
||||
}
|
||||
return s;
|
||||
>s : string
|
||||
}
|
||||
|
||||
function good1(e: MyEnum): string {
|
||||
>good1 : (e: MyEnum) => string
|
||||
>e : MyEnum
|
||||
|
||||
let s: string;
|
||||
>s : string
|
||||
|
||||
switch (e) {
|
||||
>e : MyEnum
|
||||
|
||||
case MyEnum.A: s = "it was A"; break;
|
||||
>MyEnum.A : MyEnum.A
|
||||
>MyEnum : typeof MyEnum
|
||||
>A : MyEnum.A
|
||||
>s = "it was A" : "it was A"
|
||||
>s : string
|
||||
>"it was A" : "it was A"
|
||||
|
||||
case MyEnum.B: s = "it was B"; break;
|
||||
>MyEnum.B : MyEnum.B
|
||||
>MyEnum : typeof MyEnum
|
||||
>B : MyEnum.B
|
||||
>s = "it was B" : "it was B"
|
||||
>s : string
|
||||
>"it was B" : "it was B"
|
||||
|
||||
default: s = "it was something else"; break;
|
||||
>s = "it was something else" : "it was something else"
|
||||
>s : string
|
||||
>"it was something else" : "it was something else"
|
||||
}
|
||||
return s;
|
||||
>s : string
|
||||
}
|
||||
|
||||
function good2(e: MyEnum): string {
|
||||
>good2 : (e: MyEnum) => string
|
||||
>e : MyEnum
|
||||
|
||||
switch (e) {
|
||||
>e : MyEnum
|
||||
|
||||
case MyEnum.A: return "it was A";
|
||||
>MyEnum.A : MyEnum.A
|
||||
>MyEnum : typeof MyEnum
|
||||
>A : MyEnum.A
|
||||
>"it was A" : "it was A"
|
||||
|
||||
case MyEnum.B: return "it was B";
|
||||
>MyEnum.B : MyEnum.B
|
||||
>MyEnum : typeof MyEnum
|
||||
>B : MyEnum.B
|
||||
>"it was B" : "it was B"
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #18362
|
||||
|
||||
enum Level {
|
||||
>Level : Level
|
||||
|
||||
One,
|
||||
>One : Level.One
|
||||
|
||||
Two,
|
||||
>Two : Level.Two
|
||||
}
|
||||
|
||||
const doSomethingWithLevel = (level: Level) => {
|
||||
>doSomethingWithLevel : (level: Level) => Level
|
||||
>(level: Level) => { let next: Level; switch (level) { case Level.One: next = Level.Two; break; case Level.Two: next = Level.One; break; } return next;} : (level: Level) => Level
|
||||
>level : Level
|
||||
|
||||
let next: Level;
|
||||
>next : Level
|
||||
|
||||
switch (level) {
|
||||
>level : Level
|
||||
|
||||
case Level.One:
|
||||
>Level.One : Level.One
|
||||
>Level : typeof Level
|
||||
>One : Level.One
|
||||
|
||||
next = Level.Two;
|
||||
>next = Level.Two : Level.Two
|
||||
>next : Level
|
||||
>Level.Two : Level.Two
|
||||
>Level : typeof Level
|
||||
>Two : Level.Two
|
||||
|
||||
break;
|
||||
case Level.Two:
|
||||
>Level.Two : Level.Two
|
||||
>Level : typeof Level
|
||||
>Two : Level.Two
|
||||
|
||||
next = Level.One;
|
||||
>next = Level.One : Level.One
|
||||
>next : Level
|
||||
>Level.One : Level.One
|
||||
>Level : typeof Level
|
||||
>One : Level.One
|
||||
|
||||
break;
|
||||
}
|
||||
return next;
|
||||
>next : Level
|
||||
|
||||
};
|
||||
|
||||
// Repro from #20409
|
||||
|
||||
interface Square2 {
|
||||
kind: "square";
|
||||
>kind : "square"
|
||||
|
||||
size: number;
|
||||
>size : number
|
||||
}
|
||||
|
||||
interface Circle2 {
|
||||
kind: "circle";
|
||||
>kind : "circle"
|
||||
|
||||
radius: number;
|
||||
>radius : number
|
||||
}
|
||||
|
||||
type Shape2 = Square2 | Circle2;
|
||||
>Shape2 : Shape2
|
||||
|
||||
function withDefault(s1: Shape2, s2: Shape2): string {
|
||||
>withDefault : (s1: Shape2, s2: Shape2) => string
|
||||
>s1 : Shape2
|
||||
>s2 : Shape2
|
||||
|
||||
switch (s1.kind) {
|
||||
>s1.kind : "square" | "circle"
|
||||
>s1 : Shape2
|
||||
>kind : "square" | "circle"
|
||||
|
||||
case "square":
|
||||
>"square" : "square"
|
||||
|
||||
return "1";
|
||||
>"1" : "1"
|
||||
|
||||
case "circle":
|
||||
>"circle" : "circle"
|
||||
|
||||
switch (s2.kind) {
|
||||
>s2.kind : "square" | "circle"
|
||||
>s2 : Shape2
|
||||
>kind : "square" | "circle"
|
||||
|
||||
case "square":
|
||||
>"square" : "square"
|
||||
|
||||
return "2";
|
||||
>"2" : "2"
|
||||
|
||||
case "circle":
|
||||
>"circle" : "circle"
|
||||
|
||||
return "3";
|
||||
>"3" : "3"
|
||||
|
||||
default:
|
||||
return "never";
|
||||
>"never" : "never"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function withoutDefault(s1: Shape2, s2: Shape2): string {
|
||||
>withoutDefault : (s1: Shape2, s2: Shape2) => string
|
||||
>s1 : Shape2
|
||||
>s2 : Shape2
|
||||
|
||||
switch (s1.kind) {
|
||||
>s1.kind : "square" | "circle"
|
||||
>s1 : Shape2
|
||||
>kind : "square" | "circle"
|
||||
|
||||
case "square":
|
||||
>"square" : "square"
|
||||
|
||||
return "1";
|
||||
>"1" : "1"
|
||||
|
||||
case "circle":
|
||||
>"circle" : "circle"
|
||||
|
||||
switch (s2.kind) {
|
||||
>s2.kind : "square" | "circle"
|
||||
>s2 : Shape2
|
||||
>kind : "square" | "circle"
|
||||
|
||||
case "square":
|
||||
>"square" : "square"
|
||||
|
||||
return "2";
|
||||
>"2" : "2"
|
||||
|
||||
case "circle":
|
||||
>"circle" : "circle"
|
||||
|
||||
return "3";
|
||||
>"3" : "3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #20823
|
||||
|
||||
function test4(value: 1 | 2) {
|
||||
>test4 : (value: 1 | 2) => string
|
||||
>value : 1 | 2
|
||||
|
||||
let x: string;
|
||||
>x : string
|
||||
|
||||
switch (value) {
|
||||
>value : 1 | 2
|
||||
|
||||
case 1: x = "one"; break;
|
||||
>1 : 1
|
||||
>x = "one" : "one"
|
||||
>x : string
|
||||
>"one" : "one"
|
||||
|
||||
case 2: x = "two"; break;
|
||||
>2 : 2
|
||||
>x = "two" : "two"
|
||||
>x : string
|
||||
>"two" : "two"
|
||||
}
|
||||
return x;
|
||||
>x : string
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(7,7): error TS2720: Class 'D' incorrectly implements class 'C<number>'. Did you mean to extend 'C<number>' and inherit its members as a subclass?
|
||||
Types of property 'bar' are incompatible.
|
||||
Type '() => string' is not assignable to type '() => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'bar()' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(12,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
@@ -16,9 +15,8 @@ tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2322:
|
||||
class D extends C<string> implements C<number> {
|
||||
~
|
||||
!!! error TS2720: Class 'D' incorrectly implements class 'C<number>'. Did you mean to extend 'C<number>' and inherit its members as a subclass?
|
||||
!!! error TS2720: Types of property 'bar' are incompatible.
|
||||
!!! error TS2720: Type '() => string' is not assignable to type '() => number'.
|
||||
!!! error TS2720: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2720: The types returned by 'bar()' are incompatible between these types.
|
||||
!!! error TS2720: Type 'string' is not assignable to type 'number'.
|
||||
baz() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No overload matches this call.
|
||||
Overload 1 of 3, '(iterable: Iterable<readonly [string, boolean]>): Map<string, boolean>', gave the following error.
|
||||
Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'Iterable<readonly [string, boolean]>'.
|
||||
Types of property '[Symbol.iterator]' are incompatible.
|
||||
Type '() => IterableIterator<[string, number] | [string, true]>' is not assignable to type '() => Iterator<readonly [string, boolean], any, undefined>'.
|
||||
Type 'IterableIterator<[string, number] | [string, true]>' is not assignable to type 'Iterator<readonly [string, boolean], any, undefined>'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, true], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<readonly [string, boolean], any>'.
|
||||
Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
|
||||
Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
|
||||
Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
|
||||
Types of property '1' are incompatible.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
|
||||
Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
|
||||
Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
|
||||
Types of property '1' are incompatible.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
@@ -23,18 +19,14 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 3, '(iterable: Iterable<readonly [string, boolean]>): Map<string, boolean>', gave the following error.
|
||||
!!! error TS2769: Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'Iterable<readonly [string, boolean]>'.
|
||||
!!! error TS2769: Types of property '[Symbol.iterator]' are incompatible.
|
||||
!!! error TS2769: Type '() => IterableIterator<[string, number] | [string, true]>' is not assignable to type '() => Iterator<readonly [string, boolean], any, undefined>'.
|
||||
!!! error TS2769: Type 'IterableIterator<[string, number] | [string, true]>' is not assignable to type 'Iterator<readonly [string, boolean], any, undefined>'.
|
||||
!!! error TS2769: Types of property 'next' are incompatible.
|
||||
!!! error TS2769: Type '(...args: [] | [undefined]) => IteratorResult<[string, number] | [string, true], any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<readonly [string, boolean], any>'.
|
||||
!!! error TS2769: Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
|
||||
!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
|
||||
!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
|
||||
!!! error TS2769: Types of property '1' are incompatible.
|
||||
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
|
||||
!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
!!! error TS2769: Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
|
||||
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
|
||||
!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
|
||||
!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
|
||||
!!! error TS2769: Types of property '1' are incompatible.
|
||||
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
|
||||
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
|
||||
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
|
||||
for (var [k, v] of map) {
|
||||
|
||||
@@ -79,8 +79,8 @@ var r7 = foo2(b);
|
||||
>b : new (x: string) => string
|
||||
|
||||
var r8 = foo2(<U>(x: U) => x); // no error expected
|
||||
>r8 : (x: string) => string
|
||||
>foo2(<U>(x: U) => x) : (x: string) => string
|
||||
>r8 : <U>(x: U) => U
|
||||
>foo2(<U>(x: U) => x) : <U>(x: U) => U
|
||||
>foo2 : <T extends (x: string) => string>(x: T) => T
|
||||
><U>(x: U) => x : <U>(x: U) => U
|
||||
>x : U
|
||||
|
||||
@@ -103,16 +103,16 @@ var c2: { <T>(x: T): T; <T>(x: T, y: T): T };
|
||||
>y : T
|
||||
|
||||
var r9 = foo(function <U>(x: U) { return x; });
|
||||
>r9 : (x: string) => string
|
||||
>foo(function <U>(x: U) { return x; }) : (x: string) => string
|
||||
>r9 : <U>(x: U) => U
|
||||
>foo(function <U>(x: U) { return x; }) : <U>(x: U) => U
|
||||
>foo : <T extends (x: string) => string>(x: T) => T
|
||||
>function <U>(x: U) { return x; } : <U>(x: U) => U
|
||||
>x : U
|
||||
>x : U
|
||||
|
||||
var r10 = foo(<U extends string>(x: U) => x);
|
||||
>r10 : (x: string) => string
|
||||
>foo(<U extends string>(x: U) => x) : (x: string) => string
|
||||
>r10 : <U extends string>(x: U) => U
|
||||
>foo(<U extends string>(x: U) => x) : <U extends string>(x: U) => U
|
||||
>foo : <T extends (x: string) => string>(x: T) => T
|
||||
><U extends string>(x: U) => x : <U extends string>(x: U) => U
|
||||
>x : U
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error TS2322: Type '() => Generator<Bar | Baz, void, undefined>' is not assignable to type '() => Iterable<Foo>'.
|
||||
Type 'Generator<Bar | Baz, void, undefined>' is not assignable to type 'Iterable<Foo>'.
|
||||
Types of property '[Symbol.iterator]' are incompatible.
|
||||
Type '() => Generator<Bar | Baz, void, undefined>' is not assignable to type '() => Iterator<Foo, any, undefined>'.
|
||||
Type 'Generator<Bar | Baz, void, undefined>' is not assignable to type 'Iterator<Foo, any, undefined>'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(...args: [] | [undefined]) => IteratorResult<Bar | Baz, void>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<Foo, any>'.
|
||||
Type 'IteratorResult<Bar | Baz, void>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorYieldResult<Foo>'.
|
||||
Type 'Bar | Baz' is not assignable to type 'Foo'.
|
||||
Property 'x' is missing in type 'Baz' but required in type 'Foo'.
|
||||
Call signature return types 'Generator<Bar | Baz, void, undefined>' and 'Iterable<Foo>' are incompatible.
|
||||
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
Type 'IteratorResult<Bar | Baz, void>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorYieldResult<Foo>'.
|
||||
Type 'Bar | Baz' is not assignable to type 'Foo'.
|
||||
Property 'x' is missing in type 'Baz' but required in type 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts (1 errors) ====
|
||||
@@ -19,17 +15,13 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error
|
||||
var g3: () => Iterable<Foo> = function* () {
|
||||
~~
|
||||
!!! error TS2322: Type '() => Generator<Bar | Baz, void, undefined>' is not assignable to type '() => Iterable<Foo>'.
|
||||
!!! error TS2322: Type 'Generator<Bar | Baz, void, undefined>' is not assignable to type 'Iterable<Foo>'.
|
||||
!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible.
|
||||
!!! error TS2322: Type '() => Generator<Bar | Baz, void, undefined>' is not assignable to type '() => Iterator<Foo, any, undefined>'.
|
||||
!!! error TS2322: Type 'Generator<Bar | Baz, void, undefined>' is not assignable to type 'Iterator<Foo, any, undefined>'.
|
||||
!!! error TS2322: Types of property 'next' are incompatible.
|
||||
!!! error TS2322: Type '(...args: [] | [undefined]) => IteratorResult<Bar | Baz, void>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<Foo, any>'.
|
||||
!!! error TS2322: Type 'IteratorResult<Bar | Baz, void>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorYieldResult<Foo>'.
|
||||
!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'.
|
||||
!!! error TS2322: Property 'x' is missing in type 'Baz' but required in type 'Foo'.
|
||||
!!! error TS2322: Call signature return types 'Generator<Bar | Baz, void, undefined>' and 'Iterable<Foo>' are incompatible.
|
||||
!!! error TS2322: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
|
||||
!!! error TS2322: Type 'IteratorResult<Bar | Baz, void>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorResult<Foo, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<Bar | Baz>' is not assignable to type 'IteratorYieldResult<Foo>'.
|
||||
!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'.
|
||||
!!! error TS2322: Property 'x' is missing in type 'Baz' but required in type 'Foo'.
|
||||
!!! related TS2728 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts:1:13: 'x' is declared here.
|
||||
yield;
|
||||
yield new Bar;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator<number, State, undefined>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
Type 'Generator<number, State, undefined>' is not assignable to type 'IterableIterator<State>'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(...args: [] | [undefined]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
|
||||
Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.
|
||||
Type 'number' is not assignable to type 'State'.
|
||||
Call signature return types 'Generator<number, State, undefined>' and 'IterableIterator<State>' are incompatible.
|
||||
The types returned by 'next(...)' are incompatible between these types.
|
||||
Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.
|
||||
Type 'number' is not assignable to type 'State'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (1 errors) ====
|
||||
@@ -35,13 +34,12 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err
|
||||
export const Nothing: Strategy<State> = strategy("Nothing", function* (state: State) {
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(state: State) => Generator<number, State, undefined>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
!!! error TS2345: Type 'Generator<number, State, undefined>' is not assignable to type 'IterableIterator<State>'.
|
||||
!!! error TS2345: Types of property 'next' are incompatible.
|
||||
!!! error TS2345: Type '(...args: [] | [undefined]) => IteratorResult<number, State>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<State, any>'.
|
||||
!!! error TS2345: Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'State'.
|
||||
!!! error TS2345: Call signature return types 'Generator<number, State, undefined>' and 'IterableIterator<State>' are incompatible.
|
||||
!!! error TS2345: The types returned by 'next(...)' are incompatible between these types.
|
||||
!!! error TS2345: Type 'IteratorResult<number, State>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorResult<State, any>'.
|
||||
!!! error TS2345: Type 'IteratorYieldResult<number>' is not assignable to type 'IteratorYieldResult<State>'.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'State'.
|
||||
yield 1;
|
||||
return state;
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error TS2322: Type 'Generator<string, any, undefined>' is not assignable to type 'BadGenerator'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(...args: [] | [undefined]) => IteratorResult<string, any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<number, any>'.
|
||||
Type 'IteratorResult<string, any>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorYieldResult<number>'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'next(...)' are incompatible between these types.
|
||||
Type 'IteratorResult<string, any>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorYieldResult<number>'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts (1 errors) ====
|
||||
@@ -12,9 +11,8 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error
|
||||
function* g3(): BadGenerator { }
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'Generator<string, any, undefined>' is not assignable to type 'BadGenerator'.
|
||||
!!! error TS2322: Types of property 'next' are incompatible.
|
||||
!!! error TS2322: Type '(...args: [] | [undefined]) => IteratorResult<string, any>' is not assignable to type '(...args: [] | [undefined]) => IteratorResult<number, any>'.
|
||||
!!! error TS2322: Type 'IteratorResult<string, any>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorYieldResult<number>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: The types returned by 'next(...)' are incompatible between these types.
|
||||
!!! error TS2322: Type 'IteratorResult<string, any>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
|
||||
!!! error TS2322: Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorYieldResult<number>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
@@ -1,8 +1,7 @@
|
||||
tests/cases/compiler/generics4.ts(7,1): error TS2322: Type 'C<Y>' is not assignable to type 'C<X>'.
|
||||
Type 'Y' is not assignable to type 'X'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '() => boolean' is not assignable to type '() => string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
The types returned by 'f()' are incompatible between these types.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/generics4.ts (1 errors) ====
|
||||
@@ -16,6 +15,5 @@ tests/cases/compiler/generics4.ts(7,1): error TS2322: Type 'C<Y>' is not assigna
|
||||
~
|
||||
!!! error TS2322: Type 'C<Y>' is not assignable to type 'C<X>'.
|
||||
!!! error TS2322: Type 'Y' is not assignable to type 'X'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '() => boolean' is not assignable to type '() => string'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|
||||
!!! error TS2322: The types returned by 'f()' are incompatible between these types.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|
||||
@@ -12,14 +12,12 @@ tests/cases/compiler/incompatibleTypes.ts(34,12): error TS2416: Property 'p1' in
|
||||
tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(i: IFoo1): void', gave the following error.
|
||||
Argument of type 'C1' is not assignable to parameter of type 'IFoo1'.
|
||||
Types of property 'p1' are incompatible.
|
||||
Type '() => string' is not assignable to type '() => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'p1()' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Overload 2 of 2, '(i: IFoo2): void', gave the following error.
|
||||
Argument of type 'C1' is not assignable to parameter of type 'IFoo2'.
|
||||
Types of property 'p1' are incompatible.
|
||||
Type '() => string' is not assignable to type '(s: string) => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types returned by 'p1(...)' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2769: No overload matches this call.
|
||||
Overload 1 of 2, '(n: { a: { a: string; }; b: string; }): number', gave the following error.
|
||||
Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ a: { a: string; }; b: string; }'.
|
||||
@@ -95,14 +93,12 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) =>
|
||||
!!! error TS2769: No overload matches this call.
|
||||
!!! error TS2769: Overload 1 of 2, '(i: IFoo1): void', gave the following error.
|
||||
!!! error TS2769: Argument of type 'C1' is not assignable to parameter of type 'IFoo1'.
|
||||
!!! error TS2769: Types of property 'p1' are incompatible.
|
||||
!!! error TS2769: Type '() => string' is not assignable to type '() => number'.
|
||||
!!! error TS2769: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2769: The types returned by 'p1()' are incompatible between these types.
|
||||
!!! error TS2769: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2769: Overload 2 of 2, '(i: IFoo2): void', gave the following error.
|
||||
!!! error TS2769: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'.
|
||||
!!! error TS2769: Types of property 'p1' are incompatible.
|
||||
!!! error TS2769: Type '() => string' is not assignable to type '(s: string) => number'.
|
||||
!!! error TS2769: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2769: The types returned by 'p1(...)' are incompatible between these types.
|
||||
!!! error TS2769: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
function of1(n: { a: { a: string; }; b: string; }): number;
|
||||
|
||||
@@ -413,9 +413,9 @@ const f1: F = () => {
|
||||
|
||||
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.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (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[]>; }
|
||||
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (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"; }
|
||||
|
||||
@@ -76,9 +76,9 @@ export class BrokenClass {
|
||||
>Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }) : Promise<void>
|
||||
>Promise.all(result.map(populateItems)) .then : <TResult1 = unknown[], TResult2 = never>(onfulfilled?: (value: unknown[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
>Promise.all(result.map(populateItems)) : Promise<unknown[]>
|
||||
>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.all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (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[]>; }
|
||||
>all : { <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [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: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>; }
|
||||
>result.map(populateItems) : Promise<unknown>[]
|
||||
>result.map : <U>(callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any) => U[]
|
||||
>result : MyModule.MyModel[]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
tests/cases/compiler/inheritedModuleMembersForClodule.ts(7,7): error TS2417: Class static side 'typeof D' incorrectly extends base class static side 'typeof C'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type '() => number' is not assignable to type '() => string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
The types returned by 'foo()' are incompatible between these types.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritedModuleMembersForClodule.ts (1 errors) ====
|
||||
@@ -14,9 +13,8 @@ tests/cases/compiler/inheritedModuleMembersForClodule.ts(7,7): error TS2417: Cla
|
||||
class D extends C {
|
||||
~
|
||||
!!! error TS2417: Class static side 'typeof D' incorrectly extends base class static side 'typeof C'.
|
||||
!!! error TS2417: Types of property 'foo' are incompatible.
|
||||
!!! error TS2417: Type '() => number' is not assignable to type '() => string'.
|
||||
!!! error TS2417: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2417: The types returned by 'foo()' are incompatible between these types.
|
||||
!!! error TS2417: Type 'number' is not assignable to type 'string'.
|
||||
}
|
||||
|
||||
module D {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseProperty2.ts(5,11): error TS2430: Interface 'Derived' incorrectly extends interface 'Base'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type '{ a: string; }' is not assignable to type '{ a: number; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
The types of 'x.a' are incompatible between these types.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseProperty2.ts (1 errors) ====
|
||||
@@ -13,10 +11,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatHidesBaseP
|
||||
interface Derived extends Base { // error
|
||||
~~~~~~~
|
||||
!!! error TS2430: Interface 'Derived' incorrectly extends interface 'Base'.
|
||||
!!! error TS2430: Types of property 'x' are incompatible.
|
||||
!!! error TS2430: Type '{ a: string; }' is not assignable to type '{ a: number; }'.
|
||||
!!! error TS2430: Types of property 'a' are incompatible.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2430: The types of 'x.a' are incompatible between these types.
|
||||
!!! error TS2430: Type 'string' is not assignable to type 'number'.
|
||||
x: {
|
||||
a: string;
|
||||
};
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(21,11): error TS2430: Interface 'Derived2' incorrectly extends interface 'Base2'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type '{ a: string; b: number; }' is not assignable to type '{ b: string; }'.
|
||||
Types of property 'b' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
The types of 'x.b' are incompatible between these types.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(52,15): error TS2320: Interface 'Derived3<T>' cannot simultaneously extend types 'Base1<number>' and 'Base2<number>'.
|
||||
Named property 'x' of types 'Base1<number>' and 'Base2<number>' are not identical.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(54,15): error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base1<number>'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type '{ a: T; b: T; }' is not assignable to type '{ a: number; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'T' is not assignable to type 'number'.
|
||||
The types of 'x.a' are incompatible between these types.
|
||||
Type 'T' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(54,15): error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base2<number>'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type '{ a: T; b: T; }' is not assignable to type '{ b: number; }'.
|
||||
Types of property 'b' are incompatible.
|
||||
Type 'T' is not assignable to type 'number'.
|
||||
The types of 'x.b' are incompatible between these types.
|
||||
Type 'T' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes.ts(60,15): error TS2430: Interface 'Derived5<T>' incorrectly extends interface 'Base1<T>'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'T' is not assignable to type '{ a: T; }'.
|
||||
@@ -47,10 +41,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa
|
||||
interface Derived2 extends Base1, Base2 { // error
|
||||
~~~~~~~~
|
||||
!!! error TS2430: Interface 'Derived2' incorrectly extends interface 'Base2'.
|
||||
!!! error TS2430: Types of property 'x' are incompatible.
|
||||
!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ b: string; }'.
|
||||
!!! error TS2430: Types of property 'b' are incompatible.
|
||||
!!! error TS2430: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2430: The types of 'x.b' are incompatible between these types.
|
||||
!!! error TS2430: Type 'number' is not assignable to type 'string'.
|
||||
x: {
|
||||
a: string; b: number;
|
||||
}
|
||||
@@ -89,16 +81,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBa
|
||||
interface Derived4<T> extends Base1<number>, Base2<number> { // error
|
||||
~~~~~~~~
|
||||
!!! error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base1<number>'.
|
||||
!!! error TS2430: Types of property 'x' are incompatible.
|
||||
!!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ a: number; }'.
|
||||
!!! error TS2430: Types of property 'a' are incompatible.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'number'.
|
||||
!!! error TS2430: The types of 'x.a' are incompatible between these types.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'number'.
|
||||
~~~~~~~~
|
||||
!!! error TS2430: Interface 'Derived4<T>' incorrectly extends interface 'Base2<number>'.
|
||||
!!! error TS2430: Types of property 'x' are incompatible.
|
||||
!!! error TS2430: Type '{ a: T; b: T; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2430: Types of property 'b' are incompatible.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'number'.
|
||||
!!! error TS2430: The types of 'x.b' are incompatible between these types.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'number'.
|
||||
x: {
|
||||
a: T; b: T;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user