Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Default tsconfig in CLI (for Deno)

Open johndeighan opened this issue 7 months ago • 6 comments

The issue is that Deno doesn't have a tsconfig.json file. On this page: https://github.com/denoland/deno/issues/51, it says that "currently, the ts config is hardcoded in runtime.ts". However, that post is from 2018, so I don't know if that's still true. But, for sure, my Deno project does not have a tsconfig.json file, so the following civet command fails:

$ civet --emit-declaration -o .ts -c test/lib2.civet
C:\Users\johnd\AppData\Roaming\npm\node_modules\@danielx\civet\dist\unplugin\unplugin.js:175
          throw new Error("Could not find 'tsconfig.json'");
                ^

Error: Could not find 'tsconfig.json'
    at Object.buildStart (C:\Users\johnd\AppData\Roaming\npm\node_modules\@danielx\civet\dist\unplugin\unplugin.js:175:17)
    at async cli (C:\Users\johnd\AppData\Roaming\npm\node_modules\@danielx\civet\dist\civet:531:5)

Node.js v23.3.0

johndeighan avatar May 28 '25 13:05 johndeighan

For what it's worth, it's --emit-declaration that's causing the error. It calls TypeScript to create the .d.ts files, and TypeScript needs a tsconfig.

Does Deno have a way of creating .d.ts files that does not need a tsconfig? (I thought Deno just ran TypeScript files, but didn't procesd the types, but I may be out of date.)

In any case, offering a default tsconfig (possibly with a warning) would be better than failing here. I've wanted the same for the LSP.

edemaine avatar May 28 '25 14:05 edemaine

I've run into an additional issue that's related to using Deno - in this case, with the civet VSCode language server. Background: I'm working on switching to using VSCode from TextPad. I love TextPad, but I'm finding that it's better to get indications about problems directly in the editor, before running commands to check or run code.

The issue is that with both the Deno and Civet language servers installed and enabled, if I open a TypeScript file that imports from another TypeScript file, I get the dreaded red squiggly under the name of the file being imported because it ends in '.ts', and that's not allowed by default in standard TypeScript, but is allowed in Deno.

I could probably find a way to set a TypeScript config to make it go away, but my fear is that there will be more and more issues like this, hence my request to fully support Deno. Basically, that comes down to using Deno's internal config whenever Deno is being used. Since I'm not sure how to safely define "Deno is being used" (it being installed, I think, isn't sufficient), perhaps civet could have a config that says "I'm using Deno" and civet would ensure that Deno's internal TypeScript config is being used.

johndeighan avatar Jun 29 '25 13:06 johndeighan

@johndeighan

You should be able to use:

{
  "parseOptions": {
    "deno": true
  }
}

In your Civet config.

STRd6 avatar Jul 01 '25 00:07 STRd6

@johndeighan

You should be able to use:

{
  "parseOptions": {
    "deno": true
  }
}

In your Civet config.

I put the file as civetconfig.json. This doesn't work with Civet's VSCode plugin.

iacore avatar Aug 11 '25 20:08 iacore

@iacore What do you mean by "This doesn't work"? And did you restart VSCode after creating the file?

edemaine avatar Aug 11 '25 20:08 edemaine

@iacore What do you mean by "This doesn't work"? And did you restart VSCode after creating the file?

I did restart VSCode. The type info is still not from deno, and Deno imports can't be resolved.

Try type checking this code in VSCode. The diagnostics will tell you it's wrong.

import { UserAgent } from "jsr:@std/http/user-agent";

Civet plugin is 0.3.28.

iacore avatar Aug 12 '25 11:08 iacore