Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): fix global namespace declaration for UMD bundle #9912

merged 3 commits into from Apr 25, 2019


None yet
2 participants
Copy link

commented Apr 23, 2019

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

In the current declaration, index.d.ts has export as namespace Vue which exposes all exported types in index.d.ts in global namespace. So the user can access them by just writing like Vue.ComponentOptions without import statement.

But this declaration is actually not correct because the Vue constructor type is declared under default which is correct in ESModule bundle but UMD bundle.

new Vue({}) // This provides compilation error in current type.

new Vue.default({}) // No compilation error.

To declare Vue constructor as just Vue in global namespace, we need to write export as namespace Vue with a common js export. So I've add umd.d.ts and do that in that file.


This comment has been minimized.

Copy link

commented Apr 25, 2019

This should not affect existing usage with ES modules right?


This comment has been minimized.

Copy link
Member Author

commented Apr 25, 2019

Right, it should not affect. The entry point (index.d.ts) exports are the same and if a file is ES module, global Vue is not available.

@yyx990803 yyx990803 merged commit ab50e8e into vuejs:dev Apr 25, 2019

3 of 5 checks passed

ci/circleci: lint-flow-types Your tests failed on CircleCI
ci/circleci: test-cover Your tests failed on CircleCI
ci/circleci: install Your tests passed on CircleCI!
ci/circleci: test-e2e Your tests passed on CircleCI!
ci/circleci: test-ssr-weex Your tests passed on CircleCI!

@ktsn ktsn deleted the ktsn:fix-umd-global-declaration branch Apr 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.