Skip to content

🤖 Pick PR #42971 (Fix: checkAliasSymbol crash when ch...) into release-4.2 #42972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36958,7 +36958,7 @@ namespace ts {
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
}

if (isImportSpecifier(node) && every(target.declarations, d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
if (isImportSpecifier(node) && target.declarations?.every(d => !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated))) {
addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName as string);
}
}
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/importPropertyFromMappedType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [tests/cases/compiler/importPropertyFromMappedType.ts] ////

//// [errors.d.ts]
// #42957

export = createHttpError;
declare const createHttpError: createHttpError.NamedConstructors;
declare namespace createHttpError {
type NamedConstructors = { [P in 'NotFound']: unknown;}
}

//// [main.ts]
import { NotFound } from './errors'


//// [main.js]
"use strict";
exports.__esModule = true;
23 changes: 23 additions & 0 deletions tests/baselines/reference/importPropertyFromMappedType.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== tests/cases/compiler/errors.d.ts ===
// #42957

export = createHttpError;
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))

declare const createHttpError: createHttpError.NamedConstructors;
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))
>NamedConstructors : Symbol(createHttpError.NamedConstructors, Decl(errors.d.ts, 4, 35))

declare namespace createHttpError {
>createHttpError : Symbol(createHttpError, Decl(errors.d.ts, 3, 13), Decl(errors.d.ts, 3, 65))

type NamedConstructors = { [P in 'NotFound']: unknown;}
>NamedConstructors : Symbol(NamedConstructors, Decl(errors.d.ts, 4, 35))
>P : Symbol(P, Decl(errors.d.ts, 5, 33))
}

=== tests/cases/compiler/main.ts ===
import { NotFound } from './errors'
>NotFound : Symbol(NotFound, Decl(main.ts, 0, 8))

19 changes: 19 additions & 0 deletions tests/baselines/reference/importPropertyFromMappedType.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== tests/cases/compiler/errors.d.ts ===
// #42957

export = createHttpError;
>createHttpError : createHttpError.NamedConstructors

declare const createHttpError: createHttpError.NamedConstructors;
>createHttpError : createHttpError.NamedConstructors
>createHttpError : any

declare namespace createHttpError {
type NamedConstructors = { [P in 'NotFound']: unknown;}
>NamedConstructors : NamedConstructors
}

=== tests/cases/compiler/main.ts ===
import { NotFound } from './errors'
>NotFound : unknown

11 changes: 11 additions & 0 deletions tests/cases/compiler/importPropertyFromMappedType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// #42957

// @filename: errors.d.ts
export = createHttpError;
declare const createHttpError: createHttpError.NamedConstructors;
declare namespace createHttpError {
type NamedConstructors = { [P in 'NotFound']: unknown;}
}

// @filename: main.ts
import { NotFound } from './errors'