Jelajahi Sumber

Fix export default in index.d.ts (#1000)

* Fix export default in index.d.ts

This breaks in Typescript 2.6 with the error "The expression of an
export assignment must be an identifier or qualified name in an ambient
context."

This commit also adds a small test that uses the default export, since
no test existed previously.

* Remove mistakenly added emacs backup file

* Do not export _default
Nathan Shively-Sanders 7 tahun lalu
induk
melakukan
0ba995e010
2 mengubah file dengan 29 tambahan dan 4 penghapusan
  1. 5 4
      types/index.d.ts
  2. 24 0
      types/test/index.ts

+ 5 - 4
types/index.d.ts

@@ -121,7 +121,8 @@ export interface ModuleTree<R> {
   [key: string]: Module<any, R>;
 }
 
-export default {
-  Store,
-  install
-};
+declare const _default: {
+  Store: typeof Store;
+  install: typeof install;
+}
+export default _default;

+ 24 - 0
types/test/index.ts

@@ -66,6 +66,30 @@ namespace RootModule {
   });
 }
 
+namespace RootDefaultModule {
+  const store = new Vuex.default.Store({
+    state: {
+      value: 0
+    },
+    getters: {
+      count: state => state.value,
+      plus10: (_, { count }) => count + 10
+    },
+    actions: {
+      foo ({ state, getters, dispatch, commit }, payload) {
+        state.value;
+        getters.count;
+        dispatch("bar", {});
+        commit("bar", {});
+      }
+    },
+    mutations: {
+      bar (state, payload) {}
+    },
+    strict: true
+  });
+}
+
 namespace NestedModules {
   interface RootState {
     a: {