Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

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

Open
@stephenkiers

Description

@stephenkiers

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

enum, npm, import

Environment

here is the yarn.lock info
react-scripts-ts@^2.16.0:
  version "2.16.0"
  resolved "https://registry.yarnpkg.com/react-scripts-ts/-/react-scripts-ts-2.16.0.tgz#45f831a12139c3b59d6bb729c1b6ef51e0f22908"
  dependencies:
    autoprefixer "7.1.6"
    babel-jest "^22.1.0"
    babel-loader "^7.1.2"
    babel-preset-react-app "^3.1.1"
    case-sensitive-paths-webpack-plugin "2.1.1"
    chalk "1.1.3"
    css-loader "0.28.7"
    dotenv "4.0.0"
    dotenv-expand "4.2.0"
    extract-text-webpack-plugin "3.0.2"
    file-loader "0.11.2"
    fork-ts-checker-webpack-plugin "^0.2.8"
    fs-extra "3.0.1"
    html-webpack-plugin "2.29.0"
    jest "22.4.2"
    object-assign "4.1.1"
    postcss-flexbugs-fixes "3.2.0"
    postcss-loader "2.0.8"
    promise "8.0.1"
    raf "3.4.0"
    react-dev-utils "^5.0.1"
    resolve "1.6.0"
    source-map-loader "^0.2.1"
    style-loader "0.19.0"
    sw-precache-webpack-plugin "0.11.4"
    ts-jest "22.0.1"
    ts-loader "^2.3.7"
    tsconfig-paths-webpack-plugin "^2.0.0"
    tslint "^5.7.0"
    tslint-config-prettier "^1.10.0"
    tslint-react "^3.2.0"
    uglifyjs-webpack-plugin "^1.1.8"
    url-loader "0.6.2"
    webpack "3.8.1"
    webpack-dev-server "2.9.4"
    webpack-manifest-plugin "1.3.2"
    whatwg-fetch "2.0.3"
  optionalDependencies:
    fsevents "^1.1.3"
node -v

v10.5.0

yarn --version

1.7.0

Then, specify:

  1. Operating system: OSX
  2. Browser and version: na

Steps to Reproduce

See attached github repro that is minimal reproduction

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

Reproducible Demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions