Skip to content

Commit 4f13aa0

Browse files
committed
Merge branch 'main' into templateLiteralTypeInferToNonString
2 parents cca166b + b975dfa commit 4f13aa0

File tree

1,099 files changed

+184668
-168756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,099 files changed

+184668
-168756
lines changed

src/compiler/checker.ts

+136-39
Large diffs are not rendered by default.

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,10 @@
27432743
"category": "Error",
27442744
"code": 2636
27452745
},
2746+
"Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.": {
2747+
"category": "Error",
2748+
"code": 2637
2749+
},
27462750

27472751
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
27482752
"category": "Error",

src/compiler/transformers/declarations.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,9 @@ namespace ts {
11631163
}
11641164

11651165
function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement) {
1166+
if (lateMarkedStatements) {
1167+
while (orderedRemoveItem(lateMarkedStatements, input));
1168+
}
11661169
if (shouldStripInternal(input)) return;
11671170
switch (input.kind) {
11681171
case SyntaxKind.ImportEqualsDeclaration: {

src/compiler/types.ts

+7
Original file line numberDiff line numberDiff line change
@@ -5915,6 +5915,13 @@ namespace ts {
59155915
nonFixingMapper: TypeMapper; // Mapper that doesn't fix inferences
59165916
returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any)
59175917
inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result
5918+
intraExpressionInferenceSites?: IntraExpressionInferenceSite[];
5919+
}
5920+
5921+
/* @internal */
5922+
export interface IntraExpressionInferenceSite {
5923+
node: Expression | MethodDeclaration;
5924+
type: Type;
59185925
}
59195926

59205927
/* @internal */

src/executeCommandLine/executeCommandLine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ namespace ts {
649649
return false;
650650
}
651651

652-
export type ExecuteCommandLineCallbacks = (program: Program | EmitAndSemanticDiagnosticsBuilderProgram | ParsedCommandLine) => void;
652+
export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void;
653653
export function executeCommandLine(
654654
system: System,
655655
cb: ExecuteCommandLineCallbacks,

src/harness/client.ts

-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ namespace ts.server {
583583
fileName: entry.file,
584584
textSpan: this.decodeSpan(entry),
585585
isWriteAccess: entry.isWriteAccess,
586-
isDefinition: false
587586
}));
588587
}
589588

src/harness/fakesHosts.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -511,18 +511,19 @@ ${indentText}${text}`;
511511
buildInfo.version = ts.version;
512512
return ts.getBuildInfoText(buildInfo);
513513
};
514+
return patchHostForBuildInfoWrite(sys, version);
515+
}
516+
517+
export function patchHostForBuildInfoWrite<T extends ts.System>(sys: T, version: string) {
514518
const originalWrite = sys.write;
515519
sys.write = msg => originalWrite.call(sys, msg.replace(ts.version, version));
516-
517-
if (sys.writeFile) {
518-
const originalWriteFile = sys.writeFile;
519-
sys.writeFile = (fileName: string, content: string, writeByteOrderMark: boolean) => {
520-
if (!ts.isBuildInfoFile(fileName)) return originalWriteFile.call(sys, fileName, content, writeByteOrderMark);
521-
const buildInfo = ts.getBuildInfo(content);
522-
buildInfo.version = version;
523-
originalWriteFile.call(sys, fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark);
524-
};
525-
}
520+
const originalWriteFile = sys.writeFile;
521+
sys.writeFile = (fileName: string, content: string, writeByteOrderMark: boolean) => {
522+
if (!ts.isBuildInfoFile(fileName)) return originalWriteFile.call(sys, fileName, content, writeByteOrderMark);
523+
const buildInfo = ts.getBuildInfo(content);
524+
buildInfo.version = version;
525+
originalWriteFile.call(sys, fileName, ts.getBuildInfoText(buildInfo), writeByteOrderMark);
526+
};
526527
return sys;
527528
}
528529

src/harness/typeWriter.ts

+33-25
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,39 @@ namespace Harness {
115115
// let type = this.checker.getTypeAtLocation(node);
116116
let type = ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) ? this.checker.getTypeAtLocation(node.parent) : undefined;
117117
if (!type || type.flags & ts.TypeFlags.Any) type = this.checker.getTypeAtLocation(node);
118-
const typeString =
119-
// Distinguish `errorType`s from `any`s; but only if the file has no errors.
120-
// Additionally,
121-
// * the LHS of a qualified name
122-
// * a binding pattern name
123-
// * labels
124-
// * the "global" in "declare global"
125-
// * the "target" in "new.target"
126-
// * names in import statements
127-
// * type-only names in export statements
128-
// * and intrinsic jsx tag names
129-
// return `error`s via `getTypeAtLocation`
130-
// But this is generally expected, so we don't call those out, either
131-
(!this.hadErrorBaseline &&
132-
type.flags & ts.TypeFlags.Any &&
133-
!ts.isBindingElement(node.parent) &&
134-
!ts.isPropertyAccessOrQualifiedName(node.parent) &&
135-
!ts.isLabelName(node) &&
136-
!(ts.isModuleDeclaration(node.parent) && ts.isGlobalScopeAugmentation(node.parent)) &&
137-
!ts.isMetaProperty(node.parent) &&
138-
!this.isImportStatementName(node) &&
139-
!this.isExportStatementName(node) &&
140-
!this.isIntrinsicJsxTag(node)) ?
141-
(type as ts.IntrinsicType).intrinsicName :
142-
this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType);
118+
// Distinguish `errorType`s from `any`s; but only if the file has no errors.
119+
// Additionally,
120+
// * the LHS of a qualified name
121+
// * a binding pattern name
122+
// * labels
123+
// * the "global" in "declare global"
124+
// * the "target" in "new.target"
125+
// * names in import statements
126+
// * type-only names in export statements
127+
// * and intrinsic jsx tag names
128+
// return `error`s via `getTypeAtLocation`
129+
// But this is generally expected, so we don't call those out, either
130+
let typeString: string;
131+
if (!this.hadErrorBaseline &&
132+
type.flags & ts.TypeFlags.Any &&
133+
!ts.isBindingElement(node.parent) &&
134+
!ts.isPropertyAccessOrQualifiedName(node.parent) &&
135+
!ts.isLabelName(node) &&
136+
!(ts.isModuleDeclaration(node.parent) && ts.isGlobalScopeAugmentation(node.parent)) &&
137+
!ts.isMetaProperty(node.parent) &&
138+
!this.isImportStatementName(node) &&
139+
!this.isExportStatementName(node) &&
140+
!this.isIntrinsicJsxTag(node)) {
141+
typeString = (type as ts.IntrinsicType).intrinsicName;
142+
}
143+
else {
144+
typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType);
145+
if (ts.isIdentifier(node) && ts.isTypeAliasDeclaration(node.parent) && node.parent.name === node && typeString === ts.idText(node)) {
146+
// for a complex type alias `type T = ...`, showing "T : T" isn't very helpful for type tests. When the type produced is the same as
147+
// the name of the type alias, recreate the type string without reusing the alias name
148+
typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType | ts.TypeFormatFlags.InTypeAlias);
149+
}
150+
}
143151
return {
144152
line: lineAndCharacter.line,
145153
syntaxKind: node.kind,

src/harness/vfsUtil.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,11 @@ namespace vfs {
809809
const baseBuffer = base._getBuffer(baseNode);
810810

811811
// no difference if both buffers are the same reference
812-
if (changedBuffer === baseBuffer) return false;
812+
if (changedBuffer === baseBuffer) {
813+
if (!options.includeChangedFileWithSameContent || changedNode.mtimeMs === baseNode.mtimeMs) return false;
814+
container[basename] = new SameFileWithModifiedTime(changedBuffer);
815+
return true;
816+
}
813817

814818
// no difference if both buffers are identical
815819
if (Buffer.compare(changedBuffer, baseBuffer) === 0) {
@@ -1391,6 +1395,12 @@ namespace vfs {
13911395
}
13921396
}
13931397

1398+
export class SameFileWithModifiedTime extends File {
1399+
constructor(data: Buffer | string, metaAndEncoding?: { encoding?: string, meta?: Record<string, any> }) {
1400+
super(data, metaAndEncoding);
1401+
}
1402+
}
1403+
13941404
/** Extended options for a hard link in a `FileSet` */
13951405
export class Link {
13961406
public readonly path: string;
@@ -1579,6 +1589,9 @@ namespace vfs {
15791589
else if (entry instanceof Directory) {
15801590
text += formatPatchWorker(file, entry.files);
15811591
}
1592+
else if (entry instanceof SameFileWithModifiedTime) {
1593+
text += `//// [${file}] file changed its modified time\r\n`;
1594+
}
15821595
else if (entry instanceof SameFileContentFile) {
15831596
text += `//// [${file}] file written with same contents\r\n`;
15841597
}

0 commit comments

Comments
 (0)