Skip to content

Commit 520413d

Browse files
committed
provide a type for forward declared variable
Summary: Recall that if another module exports a type (e.g. an interface), tsickle will create a Closure @record variable from it in the other module. When this module imports that type, for Closure purposes we need to declare a reference to the *value* of that record variable. But at TS compilation time that @record doesn't yet exist, so we must forward declare it using "declare". This change gives that forward declaration a type. By the time Closure gets to compilations using this variable, this declaration has entirely disappeared; it's just to make the TS compiler happy in the interim. More work on #112. Reviewers: rkirov Reviewed By: rkirov Subscribers: typescript-eng Differential Revision: https://reviews.angular.io/D153
1 parent c5e2a21 commit 520413d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/tsickle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class Annotator extends Rewriter {
446446
if (!isValue) {
447447
// Once tsickle processes the other module, it will create a var for it.
448448
// But until then we just hack this symbol in to the value namespace.
449-
this.emit(`declare var tsickle_${name};\n`);
449+
this.emit(`declare var tsickle_${name}: any;\n`);
450450
}
451451
this.emit(`const ${name} = tsickle_${name};\n`);
452452
this.emit(`type ${name} = tsickle_${name};\n`);

test_files/jsdoc_types/jsdoc_types.tsickle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const RenamedClassTwo = tsickle_RenamedClassTwo;
1717
type RenamedClassTwo = tsickle_RenamedClassTwo;
1818

1919
import {Interface as tsickle_Interface,} from './module2';
20-
declare var tsickle_Interface;
20+
declare var tsickle_Interface: any;
2121
const Interface = tsickle_Interface;
2222
type Interface = tsickle_Interface;
2323

0 commit comments

Comments
 (0)