Skip to content

Commit 4c718cd

Browse files
authored
Merge branch 'main' into feat/es2025-target
2 parents 06350b4 + 43db4c1 commit 4c718cd

File tree

250 files changed

+2856
-1808
lines changed

Some content is hidden

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

250 files changed

+2856
-1808
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ jobs:
211211
node-version: 'lts/*'
212212
- run: npm ci
213213

214-
- uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
214+
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
215215
with:
216216
path: ~/.cache/dprint
217217
key: ${{ runner.os }}-dprint-${{ hashFiles('package-lock.json', '.dprint.jsonc') }}

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@19b2f06db2b6f5108140aeb04014ef02b648f789 # v4.31.11
49+
uses: github/codeql-action/init@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
5050
with:
5151
config-file: ./.github/codeql/codeql-configuration.yml
5252
# Override language selection by uncommenting this and choosing your languages
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below).
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@19b2f06db2b6f5108140aeb04014ef02b648f789 # v4.31.11
59+
uses: github/codeql-action/autobuild@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,4 +70,4 @@ jobs:
7070
# make release
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@19b2f06db2b6f5108140aeb04014ef02b648f789 # v4.31.11
73+
uses: github/codeql-action/analyze@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the results to GitHub's code scanning dashboard.
5757
- name: 'Upload to code-scanning'
58-
uses: github/codeql-action/upload-sarif@19b2f06db2b6f5108140aeb04014ef02b648f789 # v4.31.11
58+
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
5959
with:
6060
sarif_file: results.sarif

src/compiler/binder.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ export const enum ContainerFlags {
488488
HasLocals = 1 << 5,
489489
IsInterface = 1 << 6,
490490
IsObjectLiteralOrClassExpressionMethodOrAccessor = 1 << 7,
491+
PropagatesThisKeyword = 1 << 8,
491492
}
492493

493494
/** @internal */
@@ -1055,7 +1056,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
10551056
currentExceptionTarget = saveExceptionTarget;
10561057
activeLabelList = saveActiveLabelList;
10571058
hasExplicitReturn = saveHasExplicitReturn;
1058-
seenThisKeyword = node.kind === SyntaxKind.ArrowFunction ? saveSeenThisKeyword || seenThisKeyword : saveSeenThisKeyword;
1059+
seenThisKeyword = containerFlags & ContainerFlags.PropagatesThisKeyword ? saveSeenThisKeyword || seenThisKeyword : saveSeenThisKeyword;
10591060
}
10601061
else if (containerFlags & ContainerFlags.IsInterface) {
10611062
const saveSeenThisKeyword = seenThisKeyword;
@@ -3845,23 +3846,26 @@ export function getContainerFlags(node: Node): ContainerFlags {
38453846
case SyntaxKind.FunctionDeclaration:
38463847
case SyntaxKind.ClassStaticBlockDeclaration:
38473848
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
3849+
38483850
case SyntaxKind.MethodSignature:
38493851
case SyntaxKind.CallSignature:
38503852
case SyntaxKind.JSDocSignature:
38513853
case SyntaxKind.JSDocFunctionType:
38523854
case SyntaxKind.FunctionType:
38533855
case SyntaxKind.ConstructSignature:
38543856
case SyntaxKind.ConstructorType:
3855-
return ContainerFlags.IsContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
3857+
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.PropagatesThisKeyword;
38563858

38573859
case SyntaxKind.JSDocImportTag:
38583860
// treat as a container to prevent using an enclosing effective host, ensuring import bindings are scoped correctly
3859-
return ContainerFlags.IsContainer | ContainerFlags.HasLocals;
3861+
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.PropagatesThisKeyword;
38603862

38613863
case SyntaxKind.FunctionExpression:
3862-
case SyntaxKind.ArrowFunction:
38633864
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsFunctionExpression;
38643865

3866+
case SyntaxKind.ArrowFunction:
3867+
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsFunctionExpression | ContainerFlags.PropagatesThisKeyword;
3868+
38653869
case SyntaxKind.ModuleBlock:
38663870
return ContainerFlags.IsControlFlowContainer;
38673871

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6774,7 +6774,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
67746774
return parentName;
67756775
}
67766776
const memberName = symbolName(type.symbol);
6777-
if (isIdentifierText(memberName, ScriptTarget.ES5)) {
6777+
if (isIdentifierText(memberName, ScriptTarget.ESNext)) {
67786778
return appendReferenceToType(
67796779
parentName as TypeReferenceNode | ImportTypeNode,
67806780
factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined),
@@ -46772,7 +46772,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4677246772
*/
4677346773
function checkClassNameCollisionWithObject(name: Identifier): void {
4677446774
if (
46775-
languageVersion >= ScriptTarget.ES5 && name.escapedText === "Object"
46775+
name.escapedText === "Object"
4677646776
&& host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < ModuleKind.ES2015
4677746777
) {
4677846778
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_and_above_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
@@ -48552,6 +48552,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4855248552
return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert);
4855348553
}
4855448554

48555+
if (!isImportAttributes && compilerOptions.ignoreDeprecations !== "6.0") {
48556+
grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert);
48557+
}
48558+
4855548559
if (declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier) === ModuleKind.CommonJS) {
4855648560
return grammarErrorOnNode(
4855748561
node,

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
26252625
}
26262626

26272627
const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None;
2628-
const allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= ScriptTarget.ES5 && !isJsonSourceFile(currentSourceFile) ? ListFormat.AllowTrailingComma : ListFormat.None;
2628+
const allowTrailingComma = currentSourceFile && !isJsonSourceFile(currentSourceFile) ? ListFormat.AllowTrailingComma : ListFormat.None;
26292629
emitList(node, node.properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine);
26302630

26312631
if (indentedFlag) {

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ export function transformTypeScript(context: TransformationContext): Transformer
879879

880880
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
881881
const facts = getClassFacts(node);
882-
const promoteToIIFE = languageVersion <= ScriptTarget.ES5 &&
882+
const promoteToIIFE = languageVersion < ScriptTarget.ES2015 &&
883883
!!(facts & ClassFacts.MayNeedImmediatelyInvokedFunctionExpression);
884884

885885
if (

src/compiler/utilities.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9034,9 +9034,23 @@ const _computedOptions = createComputedCompilerOptions({
90349034
module: {
90359035
dependencies: ["target"],
90369036
computeValue: (compilerOptions): ModuleKind => {
9037-
return typeof compilerOptions.module === "number" ?
9038-
compilerOptions.module :
9039-
_computedOptions.target.computeValue(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
9037+
if (typeof compilerOptions.module === "number") {
9038+
return compilerOptions.module;
9039+
}
9040+
const target = _computedOptions.target.computeValue(compilerOptions);
9041+
if (target === ScriptTarget.ESNext) {
9042+
return ModuleKind.ESNext;
9043+
}
9044+
if (target >= ScriptTarget.ES2022) {
9045+
return ModuleKind.ES2022;
9046+
}
9047+
if (target >= ScriptTarget.ES2020) {
9048+
return ModuleKind.ES2020;
9049+
}
9050+
if (target >= ScriptTarget.ES2015) {
9051+
return ModuleKind.ES2015;
9052+
}
9053+
return ModuleKind.CommonJS;
90409054
},
90419055
},
90429056
moduleResolution: {

src/harness/typeWriter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ export class TypeWriterWalker {
245245
return undefined;
246246
}
247247

248+
if (ts.isOmittedExpression(node)) {
249+
return undefined;
250+
}
251+
248252
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
249253
// let type = this.checker.getTypeAtLocation(node);
250254
let type = ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) ? this.checker.getTypeAtLocation(node.parent) : undefined;

tests/baselines/reference/arrayBindingPatternOmittedExpressions.types

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ var results: string[];
77

88
{
99
let [, b, , a] = results;
10-
> : undefined
11-
> : ^^^^^^^^^
1210
>b : string
1311
> : ^^^^^^
14-
> : undefined
15-
> : ^^^^^^^^^
1612
>a : string
1713
> : ^^^^^^
1814
>results : string[]
@@ -38,26 +34,12 @@ var results: string[];
3834
function f([, a, , b, , , , s, , , ] = results) {
3935
>f : ([, a, , b, , , , s, , ,]?: string[]) => void
4036
> : ^ ^^^^^^^^^^^^^^^^^^^^
41-
> : undefined
42-
> : ^^^^^^^^^
4337
>a : string
4438
> : ^^^^^^
45-
> : undefined
46-
> : ^^^^^^^^^
4739
>b : string
4840
> : ^^^^^^
49-
> : undefined
50-
> : ^^^^^^^^^
51-
> : undefined
52-
> : ^^^^^^^^^
53-
> : undefined
54-
> : ^^^^^^^^^
5541
>s : string
5642
> : ^^^^^^
57-
> : undefined
58-
> : ^^^^^^^^^
59-
> : undefined
60-
> : ^^^^^^^^^
6143
>results : string[]
6244
> : ^^^^^^^^
6345

0 commit comments

Comments
 (0)