ts ignores

This commit is contained in:
hatim boufnichel 2020-08-27 21:38:24 +02:00
parent c13a33f3df
commit 873d9f5b74
8 changed files with 25 additions and 10 deletions

View file

@ -74,6 +74,7 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => {
const newOutgoingFeedID = await new Promise((res, rej) => { const newOutgoingFeedID = await new Promise((res, rej) => {
const _outFeedNode = user const _outFeedNode = user
.get(Key.OUTGOINGS) .get(Key.OUTGOINGS)
//@ts-ignore
.set(newPartialOutgoingFeed, ack => { .set(newPartialOutgoingFeed, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej(new Error(ack.err)) rej(new Error(ack.err))
@ -98,6 +99,7 @@ const __createOutgoingFeed = async (withPublicKey, user, SEA) => {
.get(Key.OUTGOINGS) .get(Key.OUTGOINGS)
.get(newOutgoingFeedID) .get(newOutgoingFeedID)
.get(Key.MESSAGES) .get(Key.MESSAGES)
//@ts-ignore
.set(initialMsg, ack => { .set(initialMsg, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej(new Error(ack.err)) rej(new Error(ack.err))
@ -591,6 +593,7 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
const hr = gun const hr = gun
.get(Key.HANDSHAKE_NODES) .get(Key.HANDSHAKE_NODES)
.get(currentHandshakeAddress) .get(currentHandshakeAddress)
//@ts-ignore
.set(handshakeRequestData, ack => { .set(handshakeRequestData, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej(new Error(`Error trying to create request: ${ack.err}`)) rej(new Error(`Error trying to create request: ${ack.err}`))
@ -627,6 +630,7 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
} }
await new Promise((res, rej) => { await new Promise((res, rej) => {
//@ts-ignore
user.get(Key.STORED_REQS).set(storedReq, ack => { user.get(Key.STORED_REQS).set(storedReq, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej( rej(
@ -959,6 +963,7 @@ const sendSpontaneousPayment = async (to, amount, memo, feeLimit) => {
.getGun() .getGun()
.get(Key.ORDER_NODES) .get(Key.ORDER_NODES)
.get(currOrderAddress) .get(currOrderAddress)
//@ts-ignore
.set(order, ack => { .set(order, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej( rej(

View file

@ -1,6 +1,7 @@
/** /**
* @format * @format
*/ */
//@ts-ignore
const Common = require('shock-common') const Common = require('shock-common')
const isFinite = require('lodash/isFinite') const isFinite = require('lodash/isFinite')
const shuffle = require('lodash/shuffle') const shuffle = require('lodash/shuffle')
@ -29,8 +30,9 @@ const calculateWallRequest = (numberOfPublicKeyGroups, pageRequested) => {
* @param {number} page * @param {number} page
* @throws {TypeError} * @throws {TypeError}
* @throws {RangeError} * @throws {RangeError}
* @returns {Promise<Common.SchemaTypes.Post[]>} * @returns {Promise<any>}
*/ */
//@returns {Promise<Common.SchemaTypes.Post[]>}
const getFeedPage = async page => { const getFeedPage = async page => {
if (!isFinite(page)) { if (!isFinite(page)) {
throw new TypeError(`Please provide an actual number for [page]`) throw new TypeError(`Please provide an actual number for [page]`)

View file

@ -47,8 +47,9 @@ exports.userToIncomingID = async pub => {
} }
/** /**
* @returns {Promise<Common.SchemaTypes.User>} * @returns {Promise<any>}
*/ */
//@returns {Promise<Common.SchemaTypes.User>}
const getMyUser = async () => { const getMyUser = async () => {
const oldProfile = await Utils.tryAndWait( const oldProfile = await Utils.tryAndWait(
(_, user) => new Promise(res => user.get(Key.PROFILE).load(res)), (_, user) => new Promise(res => user.get(Key.PROFILE).load(res)),
@ -85,7 +86,7 @@ const getMyUser = async () => {
(_, user) => Promise.resolve(user.is && user.is.pub), (_, user) => Promise.resolve(user.is && user.is.pub),
v => typeof v !== 'string' v => typeof v !== 'string'
) )
//@ts-ignore
/** @type {Common.SchemaTypes.User} */ /** @type {Common.SchemaTypes.User} */
const u = { const u = {
avatar: oldProfile.avatar, avatar: oldProfile.avatar,

View file

@ -9,8 +9,9 @@ const Utils = require('../utils')
/** /**
* @param {string} publicKey * @param {string} publicKey
* @returns {Promise<Common.SchemaTypes.User>} * @returns {Promise<any>}
*/ */
//@returns {Promise<Common.SchemaTypes.User>}
const getAnUser = async publicKey => { const getAnUser = async publicKey => {
const oldProfile = await Utils.tryAndWait( const oldProfile = await Utils.tryAndWait(
(g, u) => { (g, u) => {
@ -47,7 +48,7 @@ const getAnUser = async publicKey => {
}, },
v => typeof v !== 'number' v => typeof v !== 'number'
) )
//@ts-ignore
/** @type {Common.SchemaTypes.User} */ /** @type {Common.SchemaTypes.User} */
const u = { const u = {
avatar: oldProfile.avatar || null, avatar: oldProfile.avatar || null,
@ -68,8 +69,9 @@ const getAnUser = async publicKey => {
module.exports.getAnUser = getAnUser module.exports.getAnUser = getAnUser
/** /**
* @returns {Promise<Common.SchemaTypes.User>} * @returns {Promise<any>}
*/ */
//@returns {Promise<Common.SchemaTypes.User>}
const getMyUser = async () => { const getMyUser = async () => {
const oldProfile = await Utils.tryAndWait( const oldProfile = await Utils.tryAndWait(
(_, user) => new Promise(res => user.get(Key.PROFILE).load(res)), (_, user) => new Promise(res => user.get(Key.PROFILE).load(res)),
@ -106,7 +108,7 @@ const getMyUser = async () => {
(_, user) => Promise.resolve(user.is && user.is.pub), (_, user) => Promise.resolve(user.is && user.is.pub),
v => typeof v !== 'string' v => typeof v !== 'string'
) )
//@ts-ignore
/** @type {Common.SchemaTypes.User} */ /** @type {Common.SchemaTypes.User} */
const u = { const u = {
avatar: oldProfile.avatar, avatar: oldProfile.avatar,

View file

@ -43,8 +43,9 @@ const getWallTotalPages = async publicKey => {
* @param {string=} publicKey * @param {string=} publicKey
* @throws {TypeError} * @throws {TypeError}
* @throws {RangeError} * @throws {RangeError}
* @returns {Promise<Common.SchemaTypes.WallPage>} * @returns {Promise<any>}
*/ */
////@returns {Promise<Common.SchemaTypes.WallPage>}
const getWallPage = async (page, publicKey) => { const getWallPage = async (page, publicKey) => {
const totalPages = await getWallTotalPages(publicKey) const totalPages = await getWallTotalPages(publicKey)
@ -103,9 +104,10 @@ const getWallPage = async (page, publicKey) => {
*/ */
const mockUser = await User.getMyUser() const mockUser = await User.getMyUser()
/** /*
* @type {Common.SchemaTypes.WallPage} * @type {Common.SchemaTypes.WallPage}
*/ */
//@ts-ignore
const thePage = await Utils.tryAndWait( const thePage = await Utils.tryAndWait(
(g, u) => { (g, u) => {
/** /**

View file

@ -154,6 +154,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
getUser() getUser()
.get(Key.ORDER_TO_RESPONSE) .get(Key.ORDER_TO_RESPONSE)
.get(orderID) .get(orderID)
//@ts-ignore
.put(orderResponse, ack => { .put(orderResponse, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
rej( rej(
@ -183,6 +184,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
getUser() getUser()
.get(Key.ORDER_TO_RESPONSE) .get(Key.ORDER_TO_RESPONSE)
.get(orderID) .get(orderID)
//@ts-ignore
.put(orderResponse, ack => { .put(orderResponse, ack => {
if (ack.err && typeof ack.err !== 'number') { if (ack.err && typeof ack.err !== 'number') {
logger.error( logger.error(

View file

@ -151,6 +151,7 @@ const onStoredReqs = cb => {
.get(Key.STORED_REQS) .get(Key.STORED_REQS)
.open(d => { .open(d => {
if (typeof d === 'object' && d !== null) { if (typeof d === 'object' && d !== null) {
//@ts-ignore
encryptedStoredReqs = /** @type {StoredRequest[]} */ (Object.values( encryptedStoredReqs = /** @type {StoredRequest[]} */ (Object.values(
d d
).filter(i => Schema.isStoredRequest(i))) ).filter(i => Schema.isStoredRequest(i)))

View file

@ -98,7 +98,7 @@ const onOpenForPubFeedPair = ([pub, feed]) =>
}) })
return return
} }
//@ts-ignore
const incoming = /** @type {import('shock-common').Schema.Outgoing} */ (data) const incoming = /** @type {import('shock-common').Schema.Outgoing} */ (data)
// incomplete data, let's not assume anything // incomplete data, let's not assume anything