question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Namespace / mangle type names made global in externs

See original GitHub issue

Currently, a TypeScript file containing ambient declarations writes out a secondary externs file:

declare interface Foo { ... }

Generates an externs.js:

/** @interface */
function Foo() {}

The problem is that Foo in the externs file is a global type, whereas the Foo in the TypeScript file was scoped to the local module. Thus, multiple Foos in multiple files can conflict.

A potential fix would be to namespace/mangle Foo as e.g. _tsickle_extern_path_to_the_file_Foo and then include an alias in the Closure output (something like var Foo = _tsickle_extern_path_to_the_file_Foo;).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mprobstcommented, Feb 7, 2017

@b-strauss within a goog.module, all symbols, including types, are scoped to the local file, and can only be seen “on the outside” through explicitly exporting them. So there’s no conflict there.

0reactions
mprobstcommented, Sep 17, 2019

Fixed a while ago.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Name Mangling in C++ - extern - Stack Overflow
1 Each name declared as an object with external linkage in a header is reserved to the implementation to designate that library object...
Read more >
Name Mangling and extern "C" in C++ - GeeksforGeeks
In C, names may not be mangled as it doesn't support function overloading. So how to make sure that name of a symbol...
Read more >
Name mangling (C++ only) - IBM
Name mangling is the encoding of function and variable names into unique names so that linkers can separate common names in the language....
Read more >
Name mangling - Wikipedia
The need for name mangling arises where the language allows different entities to be named with the same identifier as long as they...
Read more >
Name mangling in C - Jens Gustedt's Blog
Most will know that C++ mangles external names in a compiler specific way such that they encode the types of function parameters and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found