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.

enums are undefined on namespace merging

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

A bug: please describe the error that you encountered Typescript declartion merging leaves, enums undefined.


export interface Test {

}

export namespace Test {
  export enum TestEnum {
    Hello='Hello',
    World='World'
  }
}

Test.TestEnum === undefined.
Test.TestEnum.Hello <-- throws error because undefined.

How To Reproduce

A bug: please include instructions how to reproduce. Issues without reproduction are likely to receive no feedback.

  1. Create some files with the above setup.
  2. Attempt to import the Test interface and use the TestEnum somewhere. It will throw an error because the TestEnum is undefined

Can you reproduce the error in the integration tests in ng-packagr? If possible, take a look at the integration/samples and try to break one of these builds!

Is the error you faced in an application importing the library Try to break the Angular CLI app in integration/consumers/ng-cli!

Expected Behaviour

A bug: please describe what behaviour or result you expected No Error

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr: 2.4.2
@angular/*: 5.2.4
typescript: 2.7.1
rxjs: 5.5.10
node: 9.8.1
npm/yarn: yarn 1.5.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kevuptoncommented, May 24, 2018

Hey @alan-agius4, tsickle has released version 0.29.0 which apparently fixes this problem. 🥂 🎊

1reaction
alan-agius4commented, Apr 30, 2018

Did you use annotateForClosureCompiler in your own project before? As without this flag tsickle won’t be used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does it mean: Enum declarations can only merge with ...
sharedDirectory/Types.ts:880:13 Type error: Enum declarations can only merge with namespace or other enum declarations. 878 | }*/ 879 |.
Read more >
Merging and Adding Functionality to Enum - Learn TypeScript
In this lesson, you will see two advanced features: merging and adding functions to enum.
Read more >
Enum Class (System) - Microsoft Learn
Provides the base class for enumerations. ... Namespace: System ... to the enumeration type even if that numeric value is not defined in...
Read more >
Enumeration in TypeScript - Gregory Pabian - Medium
Interestingly enough, we are allowed to merge multiple const enum statements across ... We can use the name of the enumeration type to...
Read more >
12 TypeScript enums: How do they work? What can they be ...
12.2 Specifying enum member values (advanced) # · A literal enum member: either has no initializer; or is initialized via a number literal...
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