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

Missing type for processor in ReplaceInFileConfig #170

Open
julrich opened this issue Sep 30, 2023 · 9 comments · May be fixed by #191
Open

Missing type for processor in ReplaceInFileConfig #170

julrich opened this issue Sep 30, 2023 · 9 comments · May be fixed by #191

Comments

@julrich
Copy link

julrich commented Sep 30, 2023

I think this one is just plain missing, right? Same for the array version of it?

https://github.com/adamreisnz/replace-in-file#custom-processor
https://github.com/adamreisnz/replace-in-file/blob/main/types/index.d.ts#L20-L31

... and after a small patch attempt locally... probably also need to make from and to optional, then?
Maybe this could be done more elegantly with some type of discriminator?

image

This looks interesting: https://stackoverflow.com/a/49265354

@adamreisnz
Copy link
Owner

Hi, if you are referring to typescript types, I haven't been managing those, but you're welcome to submit a PR to fix if needed. Thanks!

@julrich
Copy link
Author

julrich commented Oct 1, 2023

Cool, I'll have a look! Who maintained these before, do you know? Maybe makes sense to coordinate. If they're just not really maintained at all currently... it should be a quick fix!

@adamreisnz
Copy link
Owner

I am not sure, you could look at the past PR's related to typescript. Not really maintained though, so you're welcome to take charge!

@julrich
Copy link
Author

julrich commented Oct 11, 2023

Cool, I'll have a go, then!

@lodossDev
Copy link

hi, what happened to this? i am not sure how to fix this using typescript?

@julrich
Copy link
Author

julrich commented Jan 10, 2024

Hey @lodossDev, we're still living with a local patch for this, as I haven't found the time to investigate this more in-depth. Don't want to contribute something that's working for us, but nobody else :D

If you're feeling experimental, you can try the patch we're currently using:

diff --git a/node_modules/replace-in-file/types/index.d.ts b/node_modules/replace-in-file/types/index.d.ts
index 97409d5..bd88df2 100644
--- a/node_modules/replace-in-file/types/index.d.ts
+++ b/node_modules/replace-in-file/types/index.d.ts
@@ -1,7 +1,5 @@
 
 declare module 'replace-in-file' {
-  export function replaceInFile(config: ReplaceInFileConfig): Promise<ReplaceResult[]>;
-  export function replaceInFile(config: ReplaceInFileConfig, cb: (error: Error, results: ReplaceResult[]) => void): void;
   export default replaceInFile;
 
   namespace replaceInFile {
@@ -11,9 +9,6 @@ declare module 'replace-in-file' {
     export function replaceInFile(config: ReplaceInFileConfig, cb: (error: Error, results: ReplaceResult[]) => void): void;
   }
 
-  export function sync(config: ReplaceInFileConfig): ReplaceResult[];
-  export function replaceInFileSync(config: ReplaceInFileConfig): ReplaceResult[];
-
   export type From = string | RegExp | FromCallback;
   export type To = string | ToCallback;

We're applying it using https://www.npmjs.com/package/patch-package

@zach-babb-ef
Copy link

I have a pr for this, but not permissions to the repo if someone wants to add me. Fwiw OP is correct. I also cleaned up the syntax of the type to make it consistent.

@adamreisnz
Copy link
Owner

You can simply submit your PR and I will review/approve it, thank you!

@julrich
Copy link
Author

julrich commented Feb 13, 2024

Thank you a lot, @zach-babb-ef 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants