Skip to content

Commit a4c977f

Browse files
committed
Merge branch 'main' into thin-tsserver-wrapper
2 parents 273e354 + 60cf791 commit a4c977f

File tree

194 files changed

+34317
-30234
lines changed

Some content is hidden

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

194 files changed

+34317
-30234
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ defaults:
2121

2222
jobs:
2323
test:
24-
runs-on: ubuntu-latest
25-
2624
strategy:
2725
fail-fast: false
2826
matrix:
27+
os:
28+
- ubuntu-latest
29+
- windows-latest
30+
- macos-14
2931
node-version:
3032
- '20'
3133
- '18'
@@ -35,9 +37,15 @@ jobs:
3537
- 'true'
3638
include:
3739
- node-version: '*'
38-
bundle: 'false'
39-
40-
name: Test Node ${{ matrix.node-version }} with --bundle=${{ matrix.bundle }}
40+
bundle: false
41+
os: ubuntu-latest
42+
exclude:
43+
# No Node 14 on ARM macOS
44+
- node-version: '14'
45+
os: macos-14
46+
47+
runs-on: ${{ matrix.os }}
48+
name: Test Node ${{ matrix.node-version }} on ${{ matrix.os }}${{ (!matrix.bundle && ' with --no-bundle') || '' }}
4149

4250
steps:
4351
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

package-lock.json

Lines changed: 315 additions & 312 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/checker.ts

Lines changed: 280 additions & 115 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export const inverseJsxOptionMap = new Map(mapIterator(jsxOptionMap.entries(), (
144144
// order in the generated program (see `getDefaultLibPriority` in program.ts). This
145145
// order also affects overload resolution when a type declared in one lib is
146146
// augmented in another lib.
147+
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
148+
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
149+
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
147150
const libEntries: [string, string][] = [
148151
// JavaScript only
149152
["es5", "lib.es5.d.ts"],

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,7 @@ const createUIStringComparer = (() => {
22522252
function createIntlCollatorStringComparer(locale: string | undefined): Comparer<string> {
22532253
// Intl.Collator.prototype.compare is bound to the collator. See NOTE in
22542254
// http://www.ecma-international.org/ecma-402/2.0/#sec-Intl.Collator.prototype.compare
2255-
const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
2255+
const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant", numeric: true }).compare;
22562256
return (a, b) => compareWithCallback(a, b, comparer);
22572257
}
22582258
})();

src/compiler/diagnosticMessages.json

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,14 @@
16371637
"category": "Error",
16381638
"code": 1496
16391639
},
1640+
"Expression must be enclosed in parentheses to be used as a decorator.": {
1641+
"category": "Error",
1642+
"code": 1497
1643+
},
1644+
"Invalid syntax in decorator.": {
1645+
"category": "Error",
1646+
"code": 1498
1647+
},
16401648

16411649
"The types of '{0}' are incompatible between these types.": {
16421650
"category": "Error",
@@ -2484,7 +2492,7 @@
24842492
"category": "Error",
24852493
"code": 2514
24862494
},
2487-
"Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": {
2495+
"Non-abstract class '{0}' does not implement inherited abstract member {1} from class '{2}'.": {
24882496
"category": "Error",
24892497
"code": 2515
24902498
},
@@ -2926,6 +2934,10 @@
29262934
"category": "Error",
29272935
"code": 2649
29282936
},
2937+
"Non-abstract class expression is missing implementations for the following members of '{0}': {1} and {2} more.": {
2938+
"category": "Error",
2939+
"code": 2650
2940+
},
29292941
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
29302942
"category": "Error",
29312943
"code": 2651
@@ -2938,6 +2950,18 @@
29382950
"category": "Error",
29392951
"code": 2653
29402952
},
2953+
"Non-abstract class '{0}' is missing implementations for the following members of '{1}': {2}.": {
2954+
"category": "Error",
2955+
"code": 2654
2956+
},
2957+
"Non-abstract class '{0}' is missing implementations for the following members of '{1}': {2} and {3} more.": {
2958+
"category": "Error",
2959+
"code": 2655
2960+
},
2961+
"Non-abstract class expression is missing implementations for the following members of '{0}': {1}.": {
2962+
"category": "Error",
2963+
"code": 2656
2964+
},
29412965
"JSX expressions must have one parent element.": {
29422966
"category": "Error",
29432967
"code": 2657
@@ -7776,6 +7800,14 @@
77767800
"category": "Message",
77777801
"code": 95193
77787802
},
7803+
"Wrap in parentheses": {
7804+
"category": "Message",
7805+
"code": 95194
7806+
},
7807+
"Wrap all invalid decorator expressions in parentheses": {
7808+
"category": "Message",
7809+
"code": 95195
7810+
},
77797811

77807812
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
77817813
"category": "Error",
@@ -7937,10 +7969,6 @@
79377969
"category": "Error",
79387970
"code": 18051
79397971
},
7940-
"Non-abstract class '{0}' does not implement all abstract members of '{1}'": {
7941-
"category": "Error",
7942-
"code": 18052
7943-
},
79447972
"Its type '{0}' is not a valid JSX element type.": {
79457973
"category": "Error",
79467974
"code": 18053

src/compiler/transformers/esnext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ const enum UsingKind {
7171

7272
/** @internal */
7373
export function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle {
74+
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
75+
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
76+
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
77+
7478
const {
7579
factory,
7680
getEmitHelperFactory: emitHelpers,

src/compiler/transformers/ts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ import {
122122
isSimpleInlineableExpression,
123123
isSourceFile,
124124
isStatement,
125+
isSyntacticallyString,
125126
isTemplateLiteral,
126127
isTryStatement,
127128
JsxOpeningElement,
@@ -1922,7 +1923,7 @@ export function transformTypeScript(context: TransformationContext) {
19221923
),
19231924
valueExpression,
19241925
);
1925-
const outerAssignment = valueExpression.kind === SyntaxKind.StringLiteral ?
1926+
const outerAssignment = isSyntacticallyString(valueExpression) ?
19261927
innerAssignment :
19271928
factory.createAssignment(
19281929
factory.createElementAccessExpression(

src/compiler/transformers/utilities.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
map,
6969
MethodDeclaration,
7070
ModifierFlags,
71+
NamedExportBindings,
7172
NamedImportBindings,
7273
NamespaceExport,
7374
Node,
@@ -109,14 +110,16 @@ export interface ExternalModuleInfo {
109110
hasExportStarsToExportValues: boolean; // whether this module contains export*
110111
}
111112

112-
function containsDefaultReference(node: NamedImportBindings | undefined) {
113+
function containsDefaultReference(node: NamedImportBindings | NamedExportBindings | undefined) {
113114
if (!node) return false;
114-
if (!isNamedImports(node)) return false;
115+
if (!isNamedImports(node) && !isNamedExports(node)) return false;
115116
return some(node.elements, isNamedDefaultReference);
116117
}
117118

118-
function isNamedDefaultReference(e: ImportSpecifier): boolean {
119-
return e.propertyName !== undefined && e.propertyName.escapedText === InternalSymbolName.Default;
119+
function isNamedDefaultReference(e: ImportSpecifier | ExportSpecifier): boolean {
120+
return e.propertyName !== undefined ?
121+
e.propertyName.escapedText === InternalSymbolName.Default :
122+
e.name.escapedText === InternalSymbolName.Default;
120123
}
121124

122125
/** @internal */
@@ -216,6 +219,7 @@ export function collectExternalModuleInfo(context: TransformationContext, source
216219
externalImports.push(node as ExportDeclaration);
217220
if (isNamedExports((node as ExportDeclaration).exportClause!)) {
218221
addExportedNamesForExportDeclaration(node as ExportDeclaration);
222+
hasImportDefault ||= containsDefaultReference((node as ExportDeclaration).exportClause);
219223
}
220224
else {
221225
const name = ((node as ExportDeclaration).exportClause as NamespaceExport).name;

src/compiler/types.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7277,6 +7277,9 @@ export const enum ScriptKind {
72777277
Deferred = 7,
72787278
}
72797279

7280+
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
7281+
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
7282+
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
72807283
export const enum ScriptTarget {
72817284
/** @deprecated */
72827285
ES3 = 0,
@@ -8035,6 +8038,65 @@ export type UniqueNameHandler = (baseName: string, checkFn?: (name: string) => b
80358038

80368039
export type EmitHelperUniqueNameCallback = (name: string) => string;
80378040

8041+
/**
8042+
* Indicates the minimum `ScriptTarget` (inclusive) after which a specific language feature is no longer transpiled.
8043+
*
8044+
* @internal
8045+
*/
8046+
export const enum LanguageFeatureMinimumTarget {
8047+
// ES2015 Features
8048+
Classes = ScriptTarget.ES2015,
8049+
ForOf = ScriptTarget.ES2015,
8050+
Generators = ScriptTarget.ES2015,
8051+
Iteration = ScriptTarget.ES2015,
8052+
SpreadElements = ScriptTarget.ES2015,
8053+
RestElements = ScriptTarget.ES2015,
8054+
TaggedTemplates = ScriptTarget.ES2015,
8055+
DestructuringAssignment = ScriptTarget.ES2015,
8056+
BindingPatterns = ScriptTarget.ES2015,
8057+
ArrowFunctions = ScriptTarget.ES2015,
8058+
BlockScopedVariables = ScriptTarget.ES2015,
8059+
ObjectAssign = ScriptTarget.ES2015,
8060+
8061+
// ES2016 Features
8062+
Exponentiation = ScriptTarget.ES2016, // `x ** y`
8063+
8064+
// ES2017 Features
8065+
AsyncFunctions = ScriptTarget.ES2017, // `async function f() {}`
8066+
8067+
// ES2018 Features
8068+
ForAwaitOf = ScriptTarget.ES2018, // `for await (const x of y)`
8069+
AsyncGenerators = ScriptTarget.ES2018, // `async function * f() { }`
8070+
AsyncIteration = ScriptTarget.ES2018, // `Symbol.asyncIterator`
8071+
ObjectSpreadRest = ScriptTarget.ES2018, // `{ ...obj }`
8072+
8073+
// ES2019 Features
8074+
BindinglessCatch = ScriptTarget.ES2019, // `try { } catch { }`
8075+
8076+
// ES2020 Features
8077+
BigInt = ScriptTarget.ES2020, // `0n`
8078+
NullishCoalesce = ScriptTarget.ES2020, // `a ?? b`
8079+
OptionalChaining = ScriptTarget.ES2020, // `a?.b`
8080+
8081+
// ES2021 Features
8082+
LogicalAssignment = ScriptTarget.ES2021, // `a ||= b`, `a &&= b`, `a ??= b`
8083+
8084+
// ES2022 Features
8085+
TopLevelAwait = ScriptTarget.ES2022,
8086+
ClassFields = ScriptTarget.ES2022,
8087+
PrivateNamesAndClassStaticBlocks = ScriptTarget.ES2022, // `class C { static {} #x = y, #m() {} }`, `#x in y`
8088+
8089+
// ES2023 Features
8090+
ShebangComments = ScriptTarget.ESNext,
8091+
8092+
// Upcoming Features
8093+
// NOTE: We must reevaluate the target for upcoming features when each successive TC39 edition is ratified in
8094+
// June of each year. This includes changes to `LanguageFeatureMinimumTarget`, `ScriptTarget`,
8095+
// transformers/esnext.ts, commandLineParser.ts, and the contents of each lib/esnext.*.d.ts file.
8096+
UsingAndAwaitUsing = ScriptTarget.ESNext, // `using x = y`, `await using x = y`
8097+
ClassAndClassElementDecorators = ScriptTarget.ESNext, // `@dec class C {}`, `class C { @dec m() {} }`
8098+
}
8099+
80388100
// dprint-ignore
80398101
/**
80408102
* Used by the checker, this enum keeps track of external emit helpers that should be type

0 commit comments

Comments
 (0)