Skip to content

Cannot avoid @types/node conflicts with libdom.d.ts #2587

@krisselden

Description

@krisselden

Describe the bug

@types/node are pulled in via transitive dependencies of @sveltejs/kit/types/index.d.ts

The problem is @types/node clobbers some libdom.d.ts definitions with incompatible node variations.

Reproduction

npm install @types/wicg-file-system-access

edit the tsconfig.json to add
"types": ["wicg-file-system-access"],

edit index.svelte to add

<script>
    /** @type {Promise<any>}*/
    let openFile = null;

    function onOpen() {
        openFile = doOpenFile();
    }

    async function doOpenFile() {
        const [handle] = await showOpenFilePicker();
        const file = await handle.getFile();
        /** @type {ReadableStream}*/
        const stream = file.stream();
        const reader = stream.getReader();
        const result = await reader.read();
        const decoder = new TextDecoder();
        return decoder.decode(result.value);
    }
</script>

<button on:click={onOpen}>Open</button>

{#await openFile}
    waiting
{:then result} 
    {result}
{/await}

file.stream() should be a ReadableStream but is a NodeJS.ReadableStream because node has clobber the type for Blob.

Logs

No response

System Info

N/A

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions