Skip to content

Commit 4eff790

Browse files
committed
Merge branch 'main' into microsoftgh-52815
2 parents e7d376f + 6dbec02 commit 4eff790

File tree

322 files changed

+977
-27787
lines changed

Some content is hidden

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

322 files changed

+977
-27787
lines changed

.github/workflows/accept-baselines-fix-lints.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
git config user.email "[email protected]"
1717
git config user.name "TypeScript Bot"
1818
npm install
19-
git rm -r --quiet tests/baselines/reference :^tests/baselines/reference/docker :^tests/baselines/reference/user
19+
git rm -r --quiet tests/baselines/reference
2020
npx hereby runtests-parallel --ci --fix || true
2121
npx hereby baseline-accept
2222
git add ./src

.gitignore

+1-22
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ tests/webTestServer.js.map
3434
tests/webhost/*.d.ts
3535
tests/webhost/webtsc.js
3636
tests/cases/**/*.js
37-
!tests/cases/docker/*.js/
3837
tests/cases/**/*.js.map
3938
*.config
4039
scripts/eslint/built/
@@ -59,29 +58,9 @@ internal/
5958
yarn.lock
6059
yarn-error.log
6160
.parallelperf.*
62-
tests/cases/user/*/package-lock.json
63-
tests/cases/user/*/node_modules/
64-
tests/cases/user/*/**/*.js
65-
tests/cases/user/*/**/*.js.map
66-
tests/cases/user/*/**/*.d.ts
67-
!tests/cases/user/zone.js/
68-
!tests/cases/user/bignumber.js/
69-
!tests/cases/user/discord.js/
7061
tests/baselines/reference/dt
7162
.failed-tests
7263
TEST-results.xml
7364
package-lock.json
74-
tests/cases/user/npm/npm
75-
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
76-
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
77-
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
78-
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
79-
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
80-
tests/cases/user/create-react-app/create-react-app
81-
tests/cases/user/fp-ts/fp-ts
82-
tests/cases/user/webpack/webpack
83-
tests/cases/user/puppeteer/puppeteer
84-
tests/cases/user/axios-src/axios-src
85-
tests/cases/user/prettier/prettier
8665
.eslintcache
87-
*v8.log
66+
*v8.log

CONTRIBUTING.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ hereby tests # Build the test infrastructure using the built compile
8181
hereby runtests # Run tests using the built compiler and test infrastructure.
8282
# You can override the specific suite runner used or specify a test for this command.
8383
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
84-
# Valid runners include conformance, compiler, fourslash, project, user, and docker
85-
# The user and docker runners are extended test suite runners - the user runner
86-
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
87-
# You'll need to have the docker executable in your system path for the docker runner to work.
84+
# Valid runners include conformance, compiler, fourslash, and project
8885
hereby runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
8986
# core count by default. Use --workers=<number> to adjust this.
9087
hereby baseline-accept # This replaces the baseline test results with the results obtained from hereby runtests.

package-lock.json

+86-86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/binder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ function initFlowNode<T extends FlowNode>(node: T) {
488488
return node;
489489
}
490490

491-
const binder = createBinder();
491+
const binder = /* @__PURE__ */ createBinder();
492492

493493
/** @internal */
494494
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {

src/compiler/utilities.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -2179,13 +2179,14 @@ function getErrorSpanForArrowFunction(sourceFile: SourceFile, node: ArrowFunctio
21792179
export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan {
21802180
let errorNode: Node | undefined = node;
21812181
switch (node.kind) {
2182-
case SyntaxKind.SourceFile:
2182+
case SyntaxKind.SourceFile: {
21832183
const pos = skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false);
21842184
if (pos === sourceFile.text.length) {
21852185
// file is empty - return span for the beginning of the file
21862186
return createTextSpan(0, 0);
21872187
}
21882188
return getSpanOfTokenAtPosition(sourceFile, pos);
2189+
}
21892190
// This list is a work in progress. Add missing node kinds to improve their error
21902191
// spans.
21912192
case SyntaxKind.VariableDeclaration:
@@ -2210,10 +2211,16 @@ export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpa
22102211
case SyntaxKind.ArrowFunction:
22112212
return getErrorSpanForArrowFunction(sourceFile, node as ArrowFunction);
22122213
case SyntaxKind.CaseClause:
2213-
case SyntaxKind.DefaultClause:
2214+
case SyntaxKind.DefaultClause: {
22142215
const start = skipTrivia(sourceFile.text, (node as CaseOrDefaultClause).pos);
22152216
const end = (node as CaseOrDefaultClause).statements.length > 0 ? (node as CaseOrDefaultClause).statements[0].pos : (node as CaseOrDefaultClause).end;
22162217
return createTextSpanFromBounds(start, end);
2218+
}
2219+
case SyntaxKind.ReturnStatement:
2220+
case SyntaxKind.YieldExpression: {
2221+
const pos = skipTrivia(sourceFile.text, (node as ReturnStatement | YieldExpression).pos);
2222+
return getSpanOfTokenAtPosition(sourceFile, pos);
2223+
}
22172224
}
22182225

22192226
if (errorNode === undefined) {

src/harness/runnerbase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "./_namespaces/Harness";
66
import * as ts from "./_namespaces/ts";
77

8-
export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt" | "docker";
8+
export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "dt";
99
export type CompilerTestKind = "conformance" | "compiler";
1010
export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
1111

src/services/codefixes/fixUnusedIdentifier.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
CancellationToken,
44
cast,
55
CodeFixAction,
6+
CodeFixContext,
67
Debug,
78
DiagnosticAndArguments,
89
DiagnosticMessage,
@@ -14,12 +15,15 @@ import {
1415
forEach,
1516
FunctionLikeDeclaration,
1617
getJSDocParameterTags,
18+
getNewLineOrDefaultFromHost,
19+
getPrecedingNonSpaceCharacterPosition,
1720
getTokenAtPosition,
1821
Identifier,
1922
ImportDeclaration,
2023
isArrayBindingPattern,
2124
isBinaryExpression,
2225
isCallExpression,
26+
isCallLikeExpression,
2327
isComputedPropertyName,
2428
isDeclarationWithTypeParameterChildren,
2529
isExpressionStatement,
@@ -37,11 +41,14 @@ import {
3741
isPrefixUnaryExpression,
3842
isPropertyAccessExpression,
3943
isSuperKeyword,
44+
isVariableDeclaration,
4045
isVariableDeclarationList,
46+
length,
4147
map,
4248
Node,
4349
ObjectBindingPattern,
4450
ParameterDeclaration,
51+
probablyUsesSemicolons,
4552
Program,
4653
showModuleSpecifier,
4754
SourceFile,
@@ -114,7 +121,7 @@ registerCodeFix({
114121
}
115122
return [
116123
createDeleteFix(textChanges.ChangeTracker.with(context, t =>
117-
t.delete(sourceFile, token.parent.parent)), Diagnostics.Remove_unused_destructuring_declaration)
124+
deleteDestructuring(context, t, sourceFile, token.parent as ObjectBindingPattern | ArrayBindingPattern)), Diagnostics.Remove_unused_destructuring_declaration),
118125
];
119126
}
120127

@@ -243,6 +250,27 @@ function deleteDestructuringElements(changes: textChanges.ChangeTracker, sourceF
243250
forEach(node.elements, n => changes.delete(sourceFile, n));
244251
}
245252

253+
function deleteDestructuring(context: CodeFixContext, changes: textChanges.ChangeTracker, sourceFile: SourceFile, { parent }: ObjectBindingPattern | ArrayBindingPattern) {
254+
if (isVariableDeclaration(parent) && parent.initializer && isCallLikeExpression(parent.initializer)) {
255+
if (isVariableDeclarationList(parent.parent) && length(parent.parent.declarations) > 1) {
256+
const varStatement = parent.parent.parent;
257+
const pos = varStatement.getStart(sourceFile);
258+
const end = varStatement.end;
259+
changes.delete(sourceFile, parent);
260+
changes.insertNodeAt(sourceFile, end, parent.initializer, {
261+
prefix: getNewLineOrDefaultFromHost(context.host, context.formatContext.options) + sourceFile.text.slice(getPrecedingNonSpaceCharacterPosition(sourceFile.text, pos - 1), pos),
262+
suffix: probablyUsesSemicolons(sourceFile) ? ";" : "",
263+
});
264+
}
265+
else {
266+
changes.replaceNode(sourceFile, parent.parent, parent.initializer);
267+
}
268+
}
269+
else {
270+
changes.delete(sourceFile, parent);
271+
}
272+
}
273+
246274
function tryPrefixDeclaration(changes: textChanges.ChangeTracker, errorCode: number, sourceFile: SourceFile, token: Node): void {
247275
// Don't offer to prefix a property.
248276
if (errorCode === Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return;

0 commit comments

Comments
 (0)