Skip to content
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
4 changes: 4 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,10 @@ namespace ts {
if (initializer) {
namespace = getSymbolOfNode(initializer);
}
// Currently, IIFEs may not have a symbol and we don't know about their contents. Give up in this case.
if (!namespace) {
return undefined;
}
if (namespace.valueDeclaration &&
isVariableDeclaration(namespace.valueDeclaration) &&
namespace.valueDeclaration.initializer &&
Expand Down
9 changes: 9 additions & 0 deletions tests/baselines/reference/typeLookupInIIFE.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=== tests/cases/conformance/salsa/a.js ===
// #22973
var ns = (function() {})();
>ns : Symbol(ns, Decl(a.js, 1, 3))

/** @type {ns.NotFound} */
var crash;
>crash : Symbol(crash, Decl(a.js, 3, 3))

12 changes: 12 additions & 0 deletions tests/baselines/reference/typeLookupInIIFE.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/conformance/salsa/a.js ===
// #22973
var ns = (function() {})();
>ns : void
>(function() {})() : void
>(function() {}) : () => void
>function() {} : () => void

/** @type {ns.NotFound} */
var crash;
>crash : any

9 changes: 9 additions & 0 deletions tests/cases/conformance/salsa/typeLookupInIIFE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: a.js
// #22973
var ns = (function() {})();
/** @type {ns.NotFound} */
var crash;