Skip to content

Commit 13b6193

Browse files
Merge remote-tracking branch 'origin/main' into release-5.4
2 parents 80ebb9d + 584b314 commit 13b6193

21 files changed

+586
-350
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
check-latest: true
7777
- run: npm ci
7878

79-
- uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
79+
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
8080
with:
8181
path: ~/.cache/dprint
8282
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@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
49+
uses: github/codeql-action/init@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1
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@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
59+
uses: github/codeql-action/autobuild@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1
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@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
73+
uses: github/codeql-action/analyze@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1

.github/workflows/release-branch-artifact.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
npm pack ./
4242
mv typescript-*.tgz typescript.tgz
4343
- name: Upload built tarfile
44-
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0
44+
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
4545
with:
4646
name: tgz
4747
path: typescript.tgz

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ jobs:
4747
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
4848
# format to the repository Actions tab.
4949
- name: 'Upload artifact'
50-
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0
50+
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
5151
with:
5252
name: SARIF file
5353
path: results.sarif
5454
retention-days: 5
5555

5656
# Upload the results to GitHub's code scanning dashboard.
5757
- name: 'Upload to code-scanning'
58-
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
58+
uses: github/codeql-action/upload-sarif@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1
5959
with:
6060
sarif_file: results.sarif

package-lock.json

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

scripts/eslint/rules/argument-trivia.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ module.exports = createRule({
177177
}
178178

179179
const getSignature = memoize(() => {
180-
if (context.parserServices?.program) {
181-
const parserServices = ESLintUtils.getParserServices(context);
180+
const parserServices = ESLintUtils.getParserServices(context, /*allowWithoutFullTypeInformation*/ true);
181+
if (parserServices.program) {
182182
const checker = parserServices.program.getTypeChecker();
183183
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
184184
return checker.getResolvedSignature(tsNode);

src/compiler/checker.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39347,20 +39347,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3934739347
}
3934839348
}
3934939349

39350-
function getNonGenericReturnTypeOfSingleCallSignature(funcType: Type) {
39350+
function getReturnTypeOfSingleNonGenericCallSignature(funcType: Type) {
3935139351
const signature = getSingleCallSignature(funcType);
39352-
if (signature) {
39353-
const returnType = getReturnTypeOfSignature(signature);
39354-
if (!signature.typeParameters || !couldContainTypeVariables(returnType)) {
39355-
return returnType;
39356-
}
39352+
if (signature && !signature.typeParameters) {
39353+
return getReturnTypeOfSignature(signature);
3935739354
}
3935839355
}
3935939356

3936039357
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr: CallChain) {
3936139358
const funcType = checkExpression(expr.expression);
3936239359
const nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
39363-
const returnType = getNonGenericReturnTypeOfSingleCallSignature(funcType);
39360+
const returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
3936439361
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
3936539362
}
3936639363

@@ -39409,7 +39406,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3940939406
// signature where we can just fetch the return type without checking the arguments.
3941039407
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !isSymbolOrSymbolForCall(expr)) {
3941139408
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
39412-
getNonGenericReturnTypeOfSingleCallSignature(checkNonNullExpression(expr.expression));
39409+
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
3941339410
}
3941439411
else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
3941539412
return getTypeFromTypeNode((expr as TypeAssertion).type);
@@ -46384,11 +46381,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4638446381
);
4638546382
}
4638646383

46387-
if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & SymbolFlags.Value)) {
46384+
if (!isIllegalExportDefaultInCJS && !(node.flags & NodeFlags.Ambient) && getIsolatedModules(compilerOptions) && !(sym.flags & SymbolFlags.Value)) {
46385+
const nonLocalMeanings = getSymbolFlags(sym, /*excludeTypeOnlyMeanings*/ false, /*excludeLocalMeanings*/ true);
4638846386
if (
4638946387
sym.flags & SymbolFlags.Alias
46390-
&& resolveAlias(sym) !== unknownSymbol
46391-
&& getSymbolFlags(sym, /*excludeTypeOnlyMeanings*/ false, /*excludeLocalMeanings*/ true) & SymbolFlags.Type
46388+
&& nonLocalMeanings & SymbolFlags.Type
46389+
&& !(nonLocalMeanings & SymbolFlags.Value)
4639246390
&& (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))
4639346391
) {
4639446392
// import { SomeType } from "./someModule";

src/compiler/moduleSpecifiers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,16 @@ function computeModuleSpecifiers(
437437
redirectPathsSpecifiers = append(redirectPathsSpecifiers, local);
438438
}
439439
else if (pathIsBareSpecifier(local)) {
440-
pathsSpecifiers = append(pathsSpecifiers, local);
440+
if (pathContainsNodeModules(local)) {
441+
// We could be in this branch due to inappropriate use of `baseUrl`, not intentional `paths`
442+
// usage. It's impossible to reason about where to prioritize baseUrl-generated module
443+
// specifiers, but if they contain `/node_modules/`, they're going to trigger a portability
444+
// error, so *at least* don't prioritize those.
445+
relativeSpecifiers = append(relativeSpecifiers, local);
446+
}
447+
else {
448+
pathsSpecifiers = append(pathsSpecifiers, local);
449+
}
441450
}
442451
else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
443452
// Why this extra conditional, not just an `else`? If some path to the file contained

tests/baselines/reference/arrayFrom.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const inputALike: ArrayLike<A> = { length: 0 };
3131
const inputARand = getEither(inputA, inputALike);
3232
>inputARand : ArrayLike<A> | Iterable<A>
3333
>getEither(inputA, inputALike) : ArrayLike<A> | Iterable<A>
34-
>getEither : <T>(in1: Iterable<T>, in2: ArrayLike<T>) => Iterable<T> | ArrayLike<T>
34+
>getEither : <T>(in1: Iterable<T>, in2: ArrayLike<T>) => ArrayLike<T> | Iterable<T>
3535
>inputA : A[]
3636
>inputALike : ArrayLike<A>
3737

@@ -163,12 +163,12 @@ const result11: B[] = Array.from(inputASet, ({ a }): B => ({ b: a }));
163163
// the ?: as always taking the false branch, narrowing to ArrayLike<T>,
164164
// even when the type is written as : Iterable<T>|ArrayLike<T>
165165
function getEither<T> (in1: Iterable<T>, in2: ArrayLike<T>) {
166-
>getEither : <T>(in1: Iterable<T>, in2: ArrayLike<T>) => Iterable<T> | ArrayLike<T>
166+
>getEither : <T>(in1: Iterable<T>, in2: ArrayLike<T>) => ArrayLike<T> | Iterable<T>
167167
>in1 : Iterable<T>
168168
>in2 : ArrayLike<T>
169169

170170
return Math.random() > 0.5 ? in1 : in2;
171-
>Math.random() > 0.5 ? in1 : in2 : Iterable<T> | ArrayLike<T>
171+
>Math.random() > 0.5 ? in1 : in2 : ArrayLike<T> | Iterable<T>
172172
>Math.random() > 0.5 : boolean
173173
>Math.random() : number
174174
>Math.random : () => number
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
circularReferenceInReturnType.ts(3,7): error TS7022: 'res1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
2+
circularReferenceInReturnType.ts(9,7): error TS7022: 'res3' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
3+
4+
5+
==== circularReferenceInReturnType.ts (2 errors) ====
6+
// inference fails for res1 and res2, but ideally should not
7+
declare function fn1<T>(cb: () => T): string;
8+
const res1 = fn1(() => res1);
9+
~~~~
10+
!!! error TS7022: 'res1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
11+
12+
declare function fn2<T>(): (cb: () => any) => (a: T) => void;
13+
const res2 = fn2()(() => res2);
14+
15+
declare function fn3<T>(): <T2>(cb: (arg: T2) => any) => (a: T) => void;
16+
const res3 = fn3()(() => res3);
17+
~~~~
18+
!!! error TS7022: 'res3' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
19+

0 commit comments

Comments
 (0)