diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-03 00:26:07 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-03 00:33:45 +0200 |
commit | a8aa74bfa858e3f9312fc27b9aff5443f84b439f (patch) | |
tree | 9cc0a527ea1190abc6f4961c6e028ecfbc1f8a6e /frontend/src | |
parent | Add TypeScript support (diff) | |
download | seven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.tar.gz seven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.tar.bz2 seven-wonders-a8aa74bfa858e3f9312fc27b9aff5443f84b439f.zip |
Convert api package to typescript
Diffstat (limited to 'frontend/src')
-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 |
3 files changed, 5 insertions, 8 deletions
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(); } |