Compare commits

...

2 Commits

Author SHA1 Message Date
Winston Chang
281dffde10 Use correct type for messages 2022-10-03 12:20:26 -05:00
Winston Chang
0f714cff34 Use es2020 2022-10-03 11:42:11 -05:00
3 changed files with 10 additions and 6 deletions

View File

@@ -79,7 +79,8 @@ async function build(
return esbuildBuild({
incremental: incremental,
watch: watch,
target: "es5",
target: "es2020",
format: "iife",
preserveSymlinks: true,
...opts,
}).then((x) => {

View File

@@ -43,6 +43,8 @@ type OnSuccessRequest = (value: ResponseValue) => void;
type OnErrorRequest = (err: string) => void;
type InputValues = { [key: string]: unknown };
type MessageValue = Parameters<WebSocket["send"]>[0];
//// 2021/03 - TypeScript conversion note:
// These four variables were moved from being internally defined to being defined globally within the file.
// Before the TypeScript conversion, the values where attached to `window.Shiny.addCustomMessageHandler()`.
@@ -127,7 +129,7 @@ class ShinyApp {
// Conditional bindings (show/hide element based on expression)
$conditionals = {};
$pendingMessages: string[] = [];
$pendingMessages: MessageValue[] = [];
$activeRequests: {
[key: number]: { onSuccess: OnSuccessRequest; onError: OnErrorRequest };
} = {};
@@ -381,7 +383,7 @@ class ShinyApp {
onError: onError,
};
let msg = JSON.stringify({
let msg: Blob | string = JSON.stringify({
method: method,
args: args,
tag: requestId,
@@ -423,13 +425,13 @@ class ShinyApp {
const blob: Blob = new Blob(payload);
msg = blob as unknown as string;
msg = blob;
}
this.$sendMsg(msg);
}
$sendMsg(msg: string): void {
$sendMsg(msg: MessageValue): void {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!this.$socket!.readyState) {
this.$pendingMessages.push(msg);

View File

@@ -1,7 +1,8 @@
{
"declaration": true,
"compilerOptions": {
"target": "ES5",
"target": "ES2020",
"moduleResolution": "node",
"isolatedModules": true,
"esModuleInterop": true,
"declaration": true,