denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.15k stars 619 forks source link

ReadableStream.from not supported if a fresh app is a subfolder #2412

Open sergeysolovev opened 4 months ago

sergeysolovev commented 4 months ago

I have a fresh app as a folder of bigger project with root deno.jsonc. I used this guide to achieve this: https://fresh.deno.dev/docs/examples/changing-the-src-dir

As a result I can not use ReadableStream.from in other part of my code which has nothing to do with the fresh app. It only works if I do both these changes in my deno.jsonc: 1) Comment out jsx and jsxImportSource in compilerOptions; 2) add folder with fresh app to the “exclude” list.

Apart that it’s a bit unexpected and difficult to find sort of issue, how to actually make it work? Would appreciate any help

marvinhagemeister commented 4 months ago

Based on the issue title and the description I tried to guess how you're using ReadableStream.from, but I feel like the description is missing that part. Can you share more about that? How do we reproduce the issue?

sergeysolovev commented 4 months ago

Sorry about vague description. By “I can not use” I meant that vscode doesn’t like the “from” word of ReadableStream.from([1, 2, 3]) expression and gives the following info in the tooltip:

Property 'from' does not exist on type '{ new (underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number | undefined; } | undefined): ReadableStream; new <R = any>(underlyingSource: UnderlyingDefaultSource<...>, strategy?: QueuingStrategy<...> | undefined): ReadableStream<...>; new <R = any>(underlyingSource?: UnderlyingSourc...'.deno-ts(2339)

The script runs and deno check gives no issues about it. So I guess this issue is related to vscode. Please let me know what else is missing

sergeysolovev commented 4 months ago

If it helps, I shared my deno.jsonc in this issue, it’s still the same.

marvinhagemeister commented 4 months ago

Thanks for providing more context. This sounds like it's a type issue. Does removing the tripple slash comments in main.ts and dev.ts help?

sergeysolovev commented 4 months ago

Oh I see. I don’t have tripple slash comments in dev.ts. Removing the from main.ts doesn’t help with the issue.

lucacasonato commented 4 months ago

I think the issue here is that Preact always loads dom types, and Deno LSP does not support different global types in different folders of a project. cc @nayeemrmn