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

Remove patch for preact/compat types #523

Merged
merged 1 commit into from
Feb 21, 2023

Conversation

zookatron
Copy link
Contributor

This patch is causing issues with recent versions of Preact:

error: TS2300 [ERROR]: Duplicate identifier 'PropsWithChildren'.
export type PropsWithChildren<P = unknown> = P & { children?: preact.ComponentChildren };
            ~~~~~~~~~~~~~~~~~
    at https://esm.sh/v106/preact@10.12.1/compat/src/index.d.ts:56:13

TS2300 [ERROR]: Duplicate identifier 'PropsWithChildren'.
	export type PropsWithChildren<P = unknown> = P & {
	            ~~~~~~~~~~~~~~~~~
    at https://esm.sh/v106/preact@10.12.1/compat/src/index.d.ts:149:14

Copy link
Member

@ije ije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe only ignore if the PropsWithChildren exists, i added this because old types don't include it

@zookatron
Copy link
Contributor Author

zookatron commented Feb 19, 2023

maybe only ignore if the PropsWithChildren exists, i added this because old types don't include it

Do you want something like this?

	// fix preact/compat types
	if pkgName == "preact" && strings.HasSuffix(savePath, "/compat/src/index.d.ts") {
		dtsData := buf.Bytes()
		if !bytes.Contains(dtsData, []byte("export type PropsWithChildren")) {
			dtsData = bytes.ReplaceAll(
				dtsData,
				[]byte("export import ComponentProps = preact.ComponentProps;"),
				[]byte("export import ComponentProps = preact.ComponentProps;\n\n// added by esm.sh\nexport type PropsWithChildren<P = unknown> = P & { children?: preact.ComponentChildren };"),
			)
			buf = bytes.NewBuffer(dtsData)
		}
	}

yes

@zookatron
Copy link
Contributor Author

@ije I've made the requested changes, let me know if that looks good to merge

@ije
Copy link
Member

ije commented Feb 21, 2023

LGTM, thanks

@ije ije merged commit 4539a4c into esm-dev:main Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants