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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰Deepmerge-ts now making typescript build hang / not responding #94

Closed
fatihaziz opened this issue Apr 5, 2022 · 11 comments 路 Fixed by #95
Closed

馃悰Deepmerge-ts now making typescript build hang / not responding #94

fatihaziz opened this issue Apr 5, 2022 · 11 comments 路 Fixed by #95
Labels
Resolution: Fixed The issue has been fixed. Status: Released It's now live. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.

Comments

@fatihaziz
Copy link
Contributor

Bug Report

It's started since last week, when I try to compile my typescript,
tsc
something wrong happen, it never done. something is stuck.

I tried to reinstall all node_modules, clean NPM cache, lastly I uninstall my node and change to version 16.14.2
none of them works...

then today, I try to install all my dependencies one by one and see if the tsc running / atleast throwing error.
when it comes to remove deepmerge-ts. it works, my tsc throwing error module not found.

having dependency to deepmerge-ts:
image

after removing
image

I tried with all version deepmerge-ts@3, @2, and @1, none of them work...

deepmerge-ts is awesome library that I need for my project, I hope it can be solved.

Expected behavior

Won't affect to tsc compiler behavior

Actual behavior

It make tsc compiler stuck

Steps to reproduce

  1. npm i deepmerge-ts
  2. npm run build or tsc
  3. getting stuck

System Environtment

  • OS: Windows 11
  • NodeJS: 16.14.2, 14.17.6
  • Typescript: 4.4.2, 4.4.4, 4.6.3
  • npm: 6, 8.5

Files:

tsconfig.json:

{
	"compileOnSave": true,
	"compilerOptions": {
		"composite": true,
		"baseUrl": "./",
		"outDir": "./lib",
		"declaration": true,
		"declarationDir": "./@types",
		"declarationMap": true,
		"target": "ES6",
		"module": "CommonJS",
		"lib": [
			"ES6",
			"ES2018",
			"ESNext",
			"DOM"
		],
		"strict": true,
		"strictPropertyInitialization": false,
		"noImplicitAny": false,
		"noImplicitThis": false,
		"pretty": true,
		"sourceMap": true,
		"allowJs": true,
		"noEmit": false,
		"moduleResolution": "node",
		"allowSyntheticDefaultImports": true,
		"forceConsistentCasingInFileNames": true,
		"esModuleInterop": true,
		"experimentalDecorators": true,
		"emitDecoratorMetadata": true,
		"useUnknownInCatchVariables": false,
		"removeComments": true,
		"typeRoots": [
			"src/@types",
			"node_modules/@types"
		]
	},
	"include": [
		"src/**/*.ts"
	],
	"exclude": [
		"dist",
		"lib",
		"node_modules",
		"tests",
		"*deprecated*",
		"*ignore*"
	]
}
@fatihaziz fatihaziz added Status: Triage This issue needs to be triaged. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors. labels Apr 5, 2022
@fatihaziz
Copy link
Contributor Author

fatihaziz commented Apr 5, 2022

I forked the repo, https://github.com/fatihaziz/deepmerge-ts-es6/compare/main...fix/ts-issue-es6
and now somehow its working fine, no more hang or not responding.

but, I still don't know the reason behind it, why the tsc compiler become not responding...

Could I upload this into npm?

@RebeccaStevens
Copy link
Owner

Give me a bit and I'll see if I can resolve this.
Would you be able to provide a minimal repo that reproduces the issue?

@fatihaziz
Copy link
Contributor Author

this is the minimal repo: here

@RebeccaStevens
Copy link
Owner

Just started looking into this now.
I haven't found the exact cause of the problem yet but the issue goes away it you use "skipLibCheck": true in your project's tsconfig.json

@fatihaziz
Copy link
Contributor Author

If we set the skipLibCheck: true typescript compiler will ignore descrepancy from the dependencies types.

Typescript server won't bother checking the types error from modules anymore. Which we won't like to do.

I think the problem is from the v04 types generated by rollup. But i never use rollup before, so i dont know what the purpose of it.

@RebeccaStevens
Copy link
Owner

What I've found so far it that it seems to be this type declaration that is causing the hang.

declare function defaultMergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, MF extends DeepMergeMergeFunctionsURIs, M>(values: Ts): Ts extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? Rest extends readonly [infer Head, ...infer Rest] ? Head extends readonly unknown[] ? Rest extends readonly [readonly unknown[], ...(readonly unknown[])[]] ? any : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head, ...Head] : never : never : [...Head, ...Head, ...Head] : never : never : [...Head, ...Head] : never : never : [...Head] : never : never;

I don't know why yet.

@fatihaziz
Copy link
Contributor Author

Maybe its goes like this:

  1. deepmerge-ts types which generated is occuring a loophole for typescript compiler.
  2. No error when compiling on the deepmerge-ts side.
  3. then, when it published. someone install it, and try to compile it, the typescript will fall into the loophole.
    And the compiler stuck.

Its weird and mindblowing for me since how types can make the compiler fall into indefinitely loophole.

This is indicated by my laptop performance when i try to compile it, the fan speed rise up higher than usually.
Which it rarely happen on normal build, that indicates there is some resource intensive task when compiling.
I try to make indefinitely while loop and run on browser and have same indication.

@RebeccaStevens
Copy link
Owner

I'm trying to debug tsc atm to see what is going on. It's possible this is an upstream problem with TypeScript itself.

@fatihaziz
Copy link
Contributor Author

Alright, i will wait for the updates then.

@RebeccaStevens RebeccaStevens removed the Status: Triage This issue needs to be triaged. label Apr 6, 2022
@RebeccaStevens
Copy link
Owner

So I'm not sure exactly what is going on but I think it is to do with the type complexity.
The type shouldn't actually be that complex, it should be aliased.

RebeccaStevens added a commit that referenced this issue Apr 6, 2022
@github-actions github-actions bot added the Resolution: Fixed The issue has been fixed. label Apr 6, 2022
github-actions bot pushed a commit that referenced this issue Apr 6, 2022
## [4.0.3](v4.0.2...v4.0.3) (2022-04-06)

### Bug Fixes

* use explict return types for function that return a HKT ([eb4183e](eb4183e)), closes [#94](#94)
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

馃帀 This issue has been resolved in version 4.0.3 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@github-actions github-actions bot added the Status: Released It's now live. label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Fixed The issue has been fixed. Status: Released It's now live. Type: Bug Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants