Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included override of Process type makes svelte-check fail #2483

Closed
benmccann opened this issue Sep 3, 2024 · 5 comments
Closed

Included override of Process type makes svelte-check fail #2483

benmccann opened this issue Sep 3, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@benmccann
Copy link
Member

benmccann commented Sep 3, 2024

Describe the bug

I get the following with svelte-check version 4 in the SvelteKit repo:

====================================
Loading svelte-check in workspace: packages/kit/test/apps/embed
Getting Svelte diagnostics...

packages/kit/test/apps/embed/../../../../../node_modules/.pnpm/@[email protected]/node_modules/@types/node/globals.d.ts:43:9
Error: Subsequent variable declarations must have the same type.  Variable 'process' must be of type 'Process & { browser: boolean; }', but here has type 'Process'. 

    var process: NodeJS.Process;
    var console: Console;


packages/kit/test/apps/embed/../../../../../node_modules/.pnpm/@[email protected]/node_modules/@types/node/process.d.ts:5:13
Error: Subsequent variable declarations must have the same type.  Variable 'process' must be of type 'Process & { browser: boolean; }', but here has type 'Process'. 
    global {
        var process: NodeJS.Process;
        namespace NodeJS {


====================================
svelte-check found 2 errors and 0 warnings in 2 files
 ELIFECYCLE  Command failed with exit code 1.

This seems to be caused by code from this repo:

./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte-check/dist/src/svelte-shims.d.ts:declare var process: NodeJS.Process & { browser: boolean }
./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte-check/dist/src/svelte-shims-v4.d.ts:declare var process: NodeJS.Process & { browser: boolean }
./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte2tsx/svelte-shims.d.ts:declare var process: NodeJS.Process & { browser: boolean }
./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/svelte2tsx/svelte-shims-v4.d.ts:declare var process: NodeJS.Process & { browser: boolean }

Reproduction

See the branch https://github.com/sveltejs/kit/tree/svelte-check-4 from sveltejs/kit#12646

Expected behaviour

I can upgrade svelte-check to v4 without issue

System Info

  • OS: Linux
  • IDE: N/A

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

@benmccann benmccann added the bug Something isn't working label Sep 3, 2024
@dummdidumm
Copy link
Member

dummdidumm commented Sep 3, 2024

This was always present (I never really noticed it until now, was added long before my time), I'm wondering why this fails now and did not earlier - likely because of the Node typings bump you did at the same time? What happens if you revert that? (not saying that is the fix, just want to clarify)

@benmccann
Copy link
Member Author

No, the Node types bump was a failed attempt at fixing the error. The error happens without that change

@jasonlyu123
Copy link
Member

It's because skipLibCheck is forced before. We probably need to use declaration merging to enhance the type.

declare namespace NodeJS {
	interface Process {
		browser: boolean
	}
}

Didn't catch this before otherwise I would want to remove it as part of breaking changes😅

@dummdidumm
Copy link
Member

I'm pretty sure it's only there because of Svelte Native, and I'm totally fine with removing this in a bug fix, and retroactively add this as a breaking change

@jasonlyu123
Copy link
Member

Seems like it's also a Webpack 4 thing. But this really doesn't seem to be needed in our shim file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants