Skip to content

Commit 2c5cee5

Browse files
authored
Fix: checkAliasSymbol crash when checking for @deprecated (#42971)
* 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. * Add bug number and accept baselines
1 parent ccdd688 commit 2c5cee5

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37124,7 +37124,7 @@ namespace ts {
3712437124
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
3712537125
}
3712637126

37127-
if (isImportSpecifier(node) && every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
37127+
if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
3712837128
addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string);
3712937129
}
3713037130
}
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)