Skip to content

Commit 9f9825a

Browse files
committed
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.
1 parent ccdd688 commit 9f9825a

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
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
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [tests/cases/compiler/importPropertyFromMappedType.ts] ////
2+
3+
//// [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+
//// [main.ts]
11+
import { NotFound } from './errors'
12+
13+
14+
//// [main.js]
15+
"use strict";
16+
exports.__esModule = true;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/errors.d.ts ===
2+
export = createHttpError;
3+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 1, 13), Decl(errors.d.ts, 1, 65))
4+
5+
declare const createHttpError: createHttpError.NamedConstructors;
6+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 1, 13), Decl(errors.d.ts, 1, 65))
7+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 1, 13), Decl(errors.d.ts, 1, 65))
8+
>NamedConstructors : Symbol(createHttpError.NamedConstructors, Decl(errors.d.ts, 2, 35))
9+
10+
declare namespace createHttpError {
11+
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 1, 13), Decl(errors.d.ts, 1, 65))
12+
13+
type NamedConstructors = { [P in 'NotFound']: unknown;}
14+
>NamedConstructors : Symbol(NamedConstructors, Decl(errors.d.ts, 2, 35))
15+
>P : Symbol(P, Decl(errors.d.ts, 3, 33))
16+
}
17+
18+
=== tests/cases/compiler/main.ts ===
19+
import { NotFound } from './errors'
20+
>NotFound : Symbol(NotFound, Decl(main.ts, 0, 8))
21+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/compiler/errors.d.ts ===
2+
export = createHttpError;
3+
>createHttpError : createHttpError.NamedConstructors
4+
5+
declare const createHttpError: createHttpError.NamedConstructors;
6+
>createHttpError : createHttpError.NamedConstructors
7+
>createHttpError : any
8+
9+
declare namespace createHttpError {
10+
type NamedConstructors = { [P in 'NotFound']: unknown;}
11+
>NamedConstructors : NamedConstructors
12+
}
13+
14+
=== tests/cases/compiler/main.ts ===
15+
import { NotFound } from './errors'
16+
>NotFound : unknown
17+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #
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)