-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'TextEncoder' refers to a value, but is being used as a type here #96
Comments
What version are you using? Can you show the code you are trying to run? |
Typescript - 5.2.2 Here is the tsconfig {
"compilerOptions": {
"lib": ["es2020"],
"module": "node16",
"esModuleInterop": true,
"target": "ES2020",
"moduleResolution": "node16",
"resolveJsonModule": true,
"sourceMap": true,
"checkJs": false,
"outDir": "dist",
"types": ["node"]
},
"include": ["./**/*.ts"],
"exclude": ["node_modules", "dist"]
} Example Code Client Service: import { AMQPChannel, AMQPClient, AMQPConsumer, AMQPQueue } from '@cloudamqp/amqp-client';
export class AmqpClientService {
static #Instance: AmqpClientService;
#client: AMQPClient;
#channel: AMQPChannel;
#connection;
#queue: AMQPQueue;
#consumer: AMQPConsumer;
private constructor(client, connection, channel, queue){
this.#client = client;
this.#channel = channel;
this.#queue = queue;
this.#connection = connection;
}
public static async init(uri: string) {
const client = new AMQPClient(uri);
const conn = await client.connect();
const ch = await conn.channel();
const q = await ch.queue();
return this.#Instance = new AmqpClientService(client, conn, ch, q);
}
async subscribe() {
try {
this.#consumer = await this.#queue.subscribe({noAck: true}, async (msg) => {
console.log(msg.bodyToString())
})
await this.#consumer.wait();
} catch (e) {
console.error('ERROR', e)
e.connection.close()
setTimeout(this.subscribe, 5000) // will try to reconnect in 1s
}
}
async publish(message) {
try {
await this.#queue.publish(message, {deliveryMode: 2});
} catch(e) {
console.error('ERROR', e)
e.connection.close()
setTimeout(this.publish, 5000, message)
}
}
async close(){
await this.#consumer.cancel();
await this.#client.close();
await this.#connection.close();
}
} bootstrap import { AmqpClientService } from '../shared/services/amqp-client-service.js'
import { ConfigurationService } from '../shared/services/configuration-service.js';
const location = 'QAUS'
const configuration = new ConfigurationService(
[
'AMQP_SERVICE_URI',
],
`.env.${location}`
);
const {
AMQP_SERVICE_URI,
} = configuration.environmentVariables;
const amqpClientService = await AmqpClientService.init(AMQP_SERVICE_URI);
amqpClientService.subscribe();
while(true){
amqpClientService.publish(`This is a test ${makeId(10)}`);
await wait(10000);
}
async function wait(time) {
return await new Promise(resolve => setTimeout(resolve, time));
}
function makeId(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
} |
Anyone? |
Same issue here, lets open a pull request? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting the following error when compiling in Typescript:
node_modules/@cloudamqp/amqp-client/types/amqp-base-client.d.ts:27:27 - error TS2749: 'TextEncoder' refers to a value, but is being used as a type here. Did you mean 'typeof TextEncoder'?
27 readonly textEncoder: TextEncoder;
This is version - 3.1.1
If I comment out
line 27 in
node_modules/@cloudamqp/amqp-client/types/amqp-base-client.d.ts
everything works.
The text was updated successfully, but these errors were encountered: