Do strict type checking on incoming data.

This commit is contained in:
Paul
2021-08-08 22:14:32 +01:00
parent 77717f5b47
commit f96059c3ff
7 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "5.0.0-alpha.20",
"version": "5.0.0-alpha.21",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+1 -1
View File
@@ -1,7 +1,7 @@
export * from './Client';
export { UserPermission, ChannelPermission, ServerPermission } from './api/permissions';
export const LIBRARY_VERSION = '5.0.0-alpha.20';
export const LIBRARY_VERSION = '5.0.0-alpha.21';
export const defaultConfig = {
apiURL: 'https://api.revolt.chat',
+1 -1
View File
@@ -188,7 +188,7 @@ export class Channel {
const apply = (key: string, target?: string) => {
// This code has been tested.
// @ts-expect-error
if (data[key] && !isEqual(this[target ?? key], data[key])) {
if (typeof data[key] !== 'undefined' && !isEqual(this[target ?? key], data[key])) {
// @ts-expect-error
this[target ?? key] = data[key];
}
+1 -1
View File
@@ -36,7 +36,7 @@ export class Member {
const apply = (key: string) => {
// This code has been tested.
// @ts-expect-error
if (data[key] && !isEqual(this[key], data[key])) {
if (typeof data[key] !== 'undefined' && !isEqual(this[key], data[key])) {
// @ts-expect-error
this[key] = data[key];
}
+1 -1
View File
@@ -92,7 +92,7 @@ export class Message {
const apply = (key: string, target?: string, transform?: (obj: unknown) => unknown) => {
// This code has been tested.
// @ts-expect-error
if (data[key] && !isEqual(this[target ?? key], data[key])) {
if (typeof data[key] !== 'undefined' && !isEqual(this[target ?? key], data[key])) {
// @ts-expect-error
this[target ?? key] = transform ? transform(data[key]) : data[key];
}
+1 -1
View File
@@ -61,7 +61,7 @@ export class Server {
const apply = (key: string, target?: string) => {
// This code has been tested.
// @ts-expect-error
if (data[key] && !isEqual(this[target ?? key], data[key])) {
if (typeof data[key] !== 'undefined' && !isEqual(this[target ?? key], data[key])) {
// @ts-expect-error
this[target ?? key] = data[key];
}
+1 -1
View File
@@ -54,7 +54,7 @@ export class User {
const apply = (key: string) => {
// This code has been tested.
// @ts-expect-error
if (data[key] && !isEqual(this[key], data[key])) {
if (typeof data[key] !== 'undefined' && !isEqual(this[key], data[key])) {
// @ts-expect-error
this[key] = data[key];