Skip to content

Const Enum undefined when imported from remote npm package in create-react-app project #25441

Closed
@stephenkiers

Description

@stephenkiers

TypeScript Version: 3.0.0-dev.20180704

Search Terms: enum, npm, yarn, import, create react app

Reproduction Github Repository
https://github.com/stephenkiers/TypescriptRepo1

Remote Package Code

export const enum TEST {
    MAJOR = "major",
    MINOR = "minor"
}

Target Package Code

type IFoo = {
    type: TEST.MINOR|TEST.MAJOR;
    name: string;
};
const foo: IFoo = {
    type: TEST.MINOR,
    name: "Full Name"
};
console.log(foo.type === TEST.MINOR ? foo.name : "World")

Expected behavior:
Target Package should print Full Name

Actual behavior:
TEST is undefined, so there is Uncaught TypeError: Cannot read property 'MINOR' of undefined

Playground Link:
Cannot recreate in playground, but made public github repo and youtube video

Related Issues: not really, but here are some possible similar issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions