lvin
lvin2y ago

importing packages breaks types

Im importing Receiver from https://deno.land/x/upstash_qstash@v0.3.2. but as soon as i import this package my types are borked
5 Replies
ioB
ioB2y ago
this is quite strange, can you reproduce this in one file? (I would try myself but am in a bus)
lvin
lvin2y ago
here is all the code
import { Status } from "https://deno.land/std@0.177.0/http/http_status.ts";
import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
import { loadManifest } from "./manifestloader.ts";
import { Receiver } from "https://deno.land/x/upstash_qstash@v0.3.6/mod.ts";

const app = new Application();
const router = new Router();

router.get("/items/:itemType", async (ctx) => {
const name = `${ctx.params.itemType}.json`;
const jsonFiles = [];
for await (const path of Deno.readDir("./assets")) {
jsonFiles.push(path.name);
}
for (const file of jsonFiles) {
if (file === name) {
const fileName = `assets/${name}`;
console.log(file, fileName);
ctx.response.status = 200;
ctx.response.headers.set("Content-Type", "application/json");
ctx.response.body = JSON.parse(await Deno.readTextFile(fileName));
}
}
ctx.response.status = Status.NotFound;
});

router.get("/process-manifest", async (ctx) => {
const token = ctx.request.headers.get("authorization");
if (token === "123") {
ctx.response.status = Status.Unauthorized;
ctx.response.body = JSON.stringify({ error: "unauthorised" });
return;
}
await loadManifest().then(() => {
ctx.response.status = 200;
ctx.response.body = JSON.stringify({ message: "success" });
});
});

app.use(router.routes());
await app.listen({ port: 8000 });
import { Status } from "https://deno.land/std@0.177.0/http/http_status.ts";
import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
import { loadManifest } from "./manifestloader.ts";
import { Receiver } from "https://deno.land/x/upstash_qstash@v0.3.6/mod.ts";

const app = new Application();
const router = new Router();

router.get("/items/:itemType", async (ctx) => {
const name = `${ctx.params.itemType}.json`;
const jsonFiles = [];
for await (const path of Deno.readDir("./assets")) {
jsonFiles.push(path.name);
}
for (const file of jsonFiles) {
if (file === name) {
const fileName = `assets/${name}`;
console.log(file, fileName);
ctx.response.status = 200;
ctx.response.headers.set("Content-Type", "application/json");
ctx.response.body = JSON.parse(await Deno.readTextFile(fileName));
}
}
ctx.response.status = Status.NotFound;
});

router.get("/process-manifest", async (ctx) => {
const token = ctx.request.headers.get("authorization");
if (token === "123") {
ctx.response.status = Status.Unauthorized;
ctx.response.body = JSON.stringify({ error: "unauthorised" });
return;
}
await loadManifest().then(() => {
ctx.response.status = 200;
ctx.response.body = JSON.stringify({ message: "success" });
});
});

app.use(router.routes());
await app.listen({ port: 8000 });
lvin
lvin2y ago
its not only specific to that one file
lvin
lvin2y ago
importing it anywhere breaks it
abi
abi2y ago
But what do they error messages actually say?