Skip to content

Commit 38bd33f

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/quick-info-index-signature-on-interface-with-base
2 parents 8f6da4b + 3af710e commit 38bd33f

30 files changed

+990
-483
lines changed

.dprint.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"newLineKind": "auto",
55
"useTabs": false,
66
"typescript": {
7+
"newLineKind": "crlf",
78
"semiColons": "always",
89
"quoteStyle": "preferDouble",
910
"quoteProps": "consistent",

.github/ISSUE_TEMPLATE/module_resolution.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ body:
1212
1313
Most module resolution bug reports are actually misconfigurations, so we require a thorough pre-investigation before we can look into any potential issues.
1414
15+
Many module problems can be automatically detected with [Are The Types Wrong?](https://arethetypeswrong.github.io/) and you should use this tool first if it appears that the module shape is wrong.
16+
1517
Let's make sure you're ready to file a module resolution bug.
1618
1719
- type: markdown

.github/workflows/ci.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ jobs:
240240
- name: Self build
241241
run: npx hereby build-src --built
242242

243-
unused-baselines:
243+
baselines:
244244
runs-on: ubuntu-latest
245245

246246
steps:
@@ -258,11 +258,22 @@ jobs:
258258
run: npm test &> /dev/null || exit 0
259259

260260
- name: Accept baselines
261-
run: npx hereby baseline-accept
261+
run: |
262+
npx hereby baseline-accept
263+
git add tests/baselines/reference
262264
263-
- name: Check for unused baselines
265+
- name: Check baselines
264266
run: |
265-
if ! git diff --exit-code --quiet; then
266-
echo "Unused baselines:"
267-
git diff --exit-code --name-only
267+
function print_diff() {
268+
if ! git diff --staged --exit-code --quiet --diff-filter=$1; then
269+
echo "$2:"
270+
git diff --staged --name-only --diff-filter=$1
271+
fi
272+
}
273+
274+
if ! git diff --staged --exit-code --quiet; then
275+
print_diff ACR "Missing baselines"
276+
print_diff MTUXB "Modified baselines"
277+
print_diff D "Unused baselines"
278+
exit 1
268279
fi

package-lock.json

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

scripts/dtsBundler.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ const dprintPath = path.resolve(__dirname, "..", "node_modules", "dprint", "bin.
417417
* @returns {string}
418418
*/
419419
function dprint(contents) {
420-
return cp.execFileSync(
420+
const result = cp.execFileSync(
421421
process.execPath,
422422
[dprintPath, "fmt", "--stdin", "ts"],
423423
{
@@ -427,6 +427,7 @@ function dprint(contents) {
427427
maxBuffer: 100 * 1024 * 1024, // 100 MB "ought to be enough for anyone"; https://github.com/nodejs/node/issues/9829
428428
},
429429
);
430+
return result.replace(/\r\n/g, "\n");
430431
}
431432

432433
fs.writeFileSync(output, dprint(publicContents));

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5111,10 +5111,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
51115111
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
51125112
const suggestedExt = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))?.[1];
51135113
if (suggestedExt) {
5114-
error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
5114+
error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
51155115
}
51165116
else {
5117-
error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
5117+
error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
51185118
}
51195119
}
51205120
else {
@@ -45014,7 +45014,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4501445014
return grammarErrorOnNode(
4501545015
declaration.assertClause,
4501645016
moduleKind === ModuleKind.NodeNext
45017-
? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
45017+
? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_CommonJS_require_calls
4501845018
: Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext,
4501945019
);
4502045020
}
@@ -49807,7 +49807,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4980749807
function getEffectivePropertyNameForPropertyNameNode(node: PropertyName) {
4980849808
const name = getPropertyNameForPropertyNameNode(node);
4980949809
return name ? name :
49810-
isComputedPropertyName(node) && isEntityNameExpression(node.expression) ? tryGetNameFromEntityNameExpression(node.expression) : undefined;
49810+
isComputedPropertyName(node) ? tryGetNameFromType(getTypeOfExpression(node.expression)) : undefined;
4981149811
}
4981249812

4981349813
function getCombinedModifierFlagsCached(node: Declaration) {

src/compiler/diagnosticMessages.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,15 +3583,15 @@
35833583
"category": "Error",
35843584
"code": 2833
35853585
},
3586-
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.": {
3586+
"Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.": {
35873587
"category": "Error",
35883588
"code": 2834
35893589
},
3590-
"Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?": {
3590+
"Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?": {
35913591
"category": "Error",
35923592
"code": 2835
35933593
},
3594-
"Import assertions are not allowed on statements that transpile to commonjs 'require' calls.": {
3594+
"Import assertions are not allowed on statements that transpile to CommonJS 'require' calls.": {
35953595
"category": "Error",
35963596
"code": 2836
35973597
},

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,9 @@ namespace Parser {
16071607
// Prime the scanner.
16081608
nextToken();
16091609
const entityName = parseEntityName(/*allowReservedWords*/ true);
1610-
const isInvalid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length;
1610+
const isValid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length;
16111611
clearState();
1612-
return isInvalid ? entityName : undefined;
1612+
return isValid ? entityName : undefined;
16131613
}
16141614

16151615
export function parseJsonText(fileName: string, sourceText: string, languageVersion: ScriptTarget = ScriptTarget.ES2015, syntaxCursor?: IncrementalParser.SyntaxCursor, setParentNodes = false): JsonSourceFile {

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6960,9 +6960,9 @@ export enum ModuleResolutionKind {
69606960
NodeJs = 2,
69616961
Node10 = 2,
69626962
// Starting with node12, node's module resolver has significant departures from traditional cjs resolution
6963-
// to better support ecmascript modules and their use within node - however more features are still being added.
6963+
// to better support ECMAScript modules and their use within node - however more features are still being added.
69646964
// TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable
6965-
// version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022.
6965+
// version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMAScript 2022.
69666966
// In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target
69676967
Node16 = 3,
69686968
NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`)

src/lib/es2023.collection.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
interface WeakKeyTypes {
2-
symbol: symbol;
3-
}
1+
interface WeakKeyTypes {
2+
symbol: symbol;
3+
}

src/lib/esnext.decorators.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/// <reference lib="es2015.symbol" />
2-
/// <reference lib="decorators" />
3-
4-
interface SymbolConstructor {
5-
readonly metadata: unique symbol;
6-
}
7-
8-
interface Function {
9-
[Symbol.metadata]: DecoratorMetadata | null;
10-
}
1+
/// <reference lib="es2015.symbol" />
2+
/// <reference lib="decorators" />
3+
4+
interface SymbolConstructor {
5+
readonly metadata: unique symbol;
6+
}
7+
8+
interface Function {
9+
[Symbol.metadata]: DecoratorMetadata | null;
10+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'?
2-
/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
1+
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'?
2+
/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
33

44

55
==== /src/foo.mts (0 errors) ====
@@ -11,8 +11,8 @@
1111
// Extensionless relative path ES import in an ES module
1212
import { foo } from "./foo"; // should error, suggest adding ".mjs"
1313
~~~~~~~
14-
!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'?
14+
!!! error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'?
1515
import { baz } from "./baz"; // should error, ask for extension, no extension suggestion
1616
~~~~~~~
17-
!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
17+
!!! error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
1818

tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'?
1+
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'?
22

33

44
==== /src/foo.tsx (0 errors) ====
@@ -10,5 +10,5 @@
1010
// Extensionless relative path ES import in an ES module
1111
import { foo } from "./foo"; // should error, suggest adding ".jsx"
1212
~~~~~~~
13-
!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'?
13+
!!! error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'?
1414

tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'?
1+
/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'?
22

33

44
==== /src/foo.tsx (0 errors) ====
@@ -10,5 +10,5 @@
1010
// Extensionless relative path ES import in an ES module
1111
import { foo } from "./foo"; // should error, suggest adding ".js"
1212
~~~~~~~
13-
!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'?
13+
!!! error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'?
1414

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
error TS2468: Cannot find global value 'Promise'.
22
/src/buzz.mts(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
3-
/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
3+
/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
44

55

66
!!! error TS2468: Cannot find global value 'Promise'.
@@ -10,4 +10,4 @@ error TS2468: Cannot find global value 'Promise'.
1010
~~~~~~~~~~~~~~~
1111
!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.
1212
~~~~~~~
13-
!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
13+
!!! error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

0 commit comments

Comments
 (0)