Skip to content

Commit d971013

Browse files
TypeScript Botsandersn
TypeScript Bot
andauthored
Cherry-pick PR #42971 into release-4.2 (#42972)
Component commits: 9f9825a Fix: checkAliasSymbol crash when checking for @deprecated It's possible that we shouldn't be creating symbol with no declarations from non-homomorphic mapped types, but for 4.2, the right fix is to make the @deprecated-check in checkAliasSymbol ensure that target.declarations is defined. 75449de Add bug number and accept baselines Co-authored-by: Nathan Shively-Sanders <nathansa@microsoft.com>
1 parent acc5fa0 commit d971013

5 files changed

+72
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36958,7 +36958,7 @@ namespace ts {
3695836958
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
3695936959
}
3696036960

36961-
if (isImportSpecifier(node) && every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
36961+
if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
3696236962
addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string);
3696336963
}
3696436964
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [tests/cases/compiler/importPropertyFromMappedType.ts] ////
2+
3+
//// [errors.d.ts]
4+
// #42957
5+
6+
export = createHttpError;
7+
declare const createHttpError: createHttpError.NamedConstructors;
8+
declare namespace createHttpError {
9+
type NamedConstructors = { [P in 'NotFound']: unknown;}
10+
}
11+
12+
//// [main.ts]
13+
import { NotFound } from './errors'
14+
15+
16+
//// [main.js]
17+
"use strict";
18+
exports.__esModule = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/errors.d.ts ===
2+
// #42957
3+
4+
export = createHttpError;
5+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
6+
7+
declare const createHttpError: createHttpError.NamedConstructors;
8+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
9+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
10+
>NamedConstructors : Symbol(createHttpError.NamedConstructors, Decl(errors.d.ts, 4, 35))
11+
12+
declare namespace createHttpError {
13+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
14+
15+
type NamedConstructors = { [P in 'NotFound']: unknown;}
16+
>NamedConstructors : Symbol(NamedConstructors, Decl(errors.d.ts, 4, 35))
17+
>P : Symbol(P, Decl(errors.d.ts, 5, 33))
18+
}
19+
20+
=== tests/cases/compiler/main.ts ===
21+
import { NotFound } from './errors'
22+
>NotFound : Symbol(NotFound, Decl(main.ts, 0, 8))
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/errors.d.ts ===
2+
// #42957
3+
4+
export = createHttpError;
5+
>createHttpError : createHttpError.NamedConstructors
6+
7+
declare const createHttpError: createHttpError.NamedConstructors;
8+
>createHttpError : createHttpError.NamedConstructors
9+
>createHttpError : any
10+
11+
declare namespace createHttpError {
12+
type NamedConstructors = { [P in 'NotFound']: unknown;}
13+
>NamedConstructors : NamedConstructors
14+
}
15+
16+
=== tests/cases/compiler/main.ts ===
17+
import { NotFound } from './errors'
18+
>NotFound : unknown
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #42957
2+
3+
// @filename: errors.d.ts
4+
export = createHttpError;
5+
declare const createHttpError: createHttpError.NamedConstructors;
6+
declare namespace createHttpError {
7+
type NamedConstructors = { [P in 'NotFound']: unknown;}
8+
}
9+
10+
// @filename: main.ts
11+
import { NotFound } from './errors'

0 commit comments

Comments
 (0)