DenoDDeno
Powered by
Yihang "Corvo" LiuY
Denoβ€’3y agoβ€’
2 replies
Yihang "Corvo" Liu

How to rewrite this code so I don't have to force deno to stop linting?

import { parse } from "https://deno.land/std@0.218.2/toml/mod.ts";
import { match } from "npm:ts-pattern@5.0.8";
// suppose options.config might be either string or undefined
  const readToml = match(options.config)
      .with(P.string, async (configPath) => { 
        return parse(await Deno.readTextFile(configPath));
      })
      // deno-lint-ignore require-await
      .with(undefined, async () => ({}))
      .exhaustive();
  console.log(await readToml);
import { parse } from "https://deno.land/std@0.218.2/toml/mod.ts";
import { match } from "npm:ts-pattern@5.0.8";
// suppose options.config might be either string or undefined
  const readToml = match(options.config)
      .with(P.string, async (configPath) => { 
        return parse(await Deno.readTextFile(configPath));
      })
      // deno-lint-ignore require-await
      .with(undefined, async () => ({}))
      .exhaustive();
  console.log(await readToml);

So here I'm matching and generating 2 promises. However the second promise is not necessary. Is there a way I can just generate the value? I tried to remove 2 asyncs and push up the async to outer function but that doesn't seem to work because await in a nested function is not allowed.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Linting browser code?
kebKkeb / help
4mo ago
Is anyone working on LLMs for Deno so I don't have to learn it in disgusting Python?
BairdyBBairdy / help
3y ago
How to stop deno jupyter caching local imports?
bartlomiejuBbartlomieju / help
2y ago