summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-03 00:26:07 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2019-05-03 00:33:45 +0200
commita8aa74bfa858e3f9312fc27b9aff5443f84b439f (patch)
tree9cc0a527ea1190abc6f4961c6e028ecfbc1f8a6e
parentAdd TypeScript support (diff)
downloadseven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.tar.gz
seven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.tar.bz2
seven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.zip
Convert api package to typescript
-rw-r--r--frontend/package.json1
-rw-r--r--frontend/src/api/model.ts (renamed from frontend/src/api/model.js)1
-rw-r--r--frontend/src/api/sevenWondersApi.ts (renamed from frontend/src/api/sevenWondersApi.js)5
-rw-r--r--frontend/src/api/websocket.ts (renamed from frontend/src/api/websocket.js)7
-rw-r--r--frontend/yarn.lock4
5 files changed, 10 insertions, 8 deletions
diff --git a/frontend/package.json b/frontend/package.json
index 6c79c6b5..cc3518ff 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -18,6 +18,7 @@
"@types/react-dom": "^16.8.4",
"@types/react-redux": "^7.0.8",
"@types/react-router-redux": "^5.0.18",
+ "@types/sockjs-client": "^1.1.1",
"history": "^4.9.0",
"http-proxy-middleware": "^0.19.1",
"immutable": "^3.8.1",
diff --git a/frontend/src/api/model.js b/frontend/src/api/model.ts
index aca4b054..efb4891e 100644
--- a/frontend/src/api/model.js
+++ b/frontend/src/api/model.ts
@@ -1,4 +1,3 @@
-// @flow
export type ApiErrorDetail = {
message: string
};
diff --git a/frontend/src/api/sevenWondersApi.js b/frontend/src/api/sevenWondersApi.ts
index 8c4aedaf..4f76a677 100644
--- a/frontend/src/api/sevenWondersApi.js
+++ b/frontend/src/api/sevenWondersApi.ts
@@ -1,5 +1,4 @@
-// @flow
-import type {
+import {
ApiError,
ApiLobby,
ApiPlayer,
@@ -9,7 +8,7 @@ import type {
ApiSettings,
ApiTable,
} from './model';
-import type { JsonStompClient, SubscribeFn } from './websocket';
+import { JsonStompClient, SubscribeFn } from './websocket';
import { createJsonStompClient } from './websocket';
const WS_URL = '/seven-wonders-websocket';
diff --git a/frontend/src/api/websocket.js b/frontend/src/api/websocket.ts
index 2fc045ff..e9393836 100644
--- a/frontend/src/api/websocket.js
+++ b/frontend/src/api/websocket.ts
@@ -1,6 +1,5 @@
-// @flow
import SockJS from 'sockjs-client';
-import type { Client, Frame, Message, Options, Subscription } from 'webstomp-client';
+import { Client, Frame, Message, Options, Subscription } from 'webstomp-client';
import * as Stomp from 'webstomp-client';
const DEFAULT_DEBUG_OPTIONS = {
@@ -18,7 +17,7 @@ export class JsonStompClient {
this.client = client;
}
- connect(headers: Object = {}): Promise<Frame | void> {
+ connect(headers: Stomp.ConnectionHeaders = {}): Promise<Frame | void> {
return new Promise((resolve, reject) => {
this.client.connect(headers, resolve, reject);
});
@@ -28,7 +27,7 @@ export class JsonStompClient {
const socketSubscription: Subscription = this.client.subscribe(path, (message: Message) => {
// not all frames have a JSON body
const value: T | void = message && JsonStompClient.parseBody(message);
- callback(value || {});
+ callback(value || {} as T);
});
return () => socketSubscription.unsubscribe();
}
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index f5902392..88ae9b91 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -1217,6 +1217,10 @@
"@types/prop-types" "*"
csstype "^2.2.0"
+"@types/sockjs-client@^1.1.1":
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/@types/sockjs-client/-/sockjs-client-1.1.1.tgz#1ef133b5a79d51447a93ce16164706c0164b5548"
+
"@types/stack-utils@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
bgstack15