Skip to content

fix: types - #233

Closed
brettz9 wants to merge 1 commit into
WebCoder49:mainfrom
brettz9:typescript
Closed

brettz9 wants to merge 1 commit into
WebCoder49:mainfrom
brettz9:typescript

Conversation

@brettz9

@brettz9 brettz9 commented Aug 29, 2026

Copy link
Copy Markdown

Hi,

Thank you for your library!

I was facing some TypeScript problems when including your library without skipLibCheck. AI came up with the attached PR.

@WebCoder49

WebCoder49 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Hi Brett,

Thanks for mentioning the TypeScript problems back upstream, and being clear about the provenance of these suggestions. A great reminder for me to test with TypeScript and that I can't just trust my ESM conversion code!

Rather than directly merging this PR, I will add necessary changes to fix the TypeScript problems, while retaining backwards compatibility. I will still credit your report!

@WebCoder49 WebCoder49 closed this Aug 30, 2026
@WebCoder49

Copy link
Copy Markdown
Owner

You can track progress for this in the typescript-tests branch.

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Excellent, thanks! Look forward to it...

WebCoder49 added a commit that referenced this pull request Sep 6, 2026
@WebCoder49

WebCoder49 commented Sep 6, 2026

Copy link
Copy Markdown
Owner

If possible, when you're available please could you test the current contents of the branch as generated by esm/generate.sh (I haven't fixed esm/generate.mjs yet but will do so very soon), with your code?

My two tests build fine so I'm quite confident it's OK. However, my patch differs from yours in several ways, for backwards compatibility, fixing more bugs I found, and avoiding unnecessary string replacements that could make bugs in the ESM version harder to track back to the initial code. Sorry for the inconvenience, but this is why I would love another test and feedback from you.

If you cannot, it's fine - just let me know and I will release a patch release that can be superseded if necessary.

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Getting these errors now:

node_modules/.pnpm/@webcoder49+code-input@https+++codeload.github.com+WebCoder49+code-input+tar.gz+23b9190_334a95884f3eb8c0b8faf6875bf85f03/node_modules/@webcoder49/code-input/esm/code-input.d.mts:154:16 - error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context.

154 export default { Plugin, Template, CodeInput, registerTemplate };
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@webcoder49+code-input@https+++codeload.github.com+WebCoder49+code-input+tar.gz+23b9190_334a95884f3eb8c0b8faf6875bf85f03/node_modules/@webcoder49/code-input/esm/plugins/indent.d.mts:3:35 - error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '../code-input.mjs' instead?

3 import { Plugin, CodeInput } from "../code-input.d.mts";
                                    ~~~~~~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/.pnpm/@webcoder49+code-input@https+++codeload.github.com+WebCoder49+code-input+tar.gz+23b9190_334a95884f3eb8c0b8faf6875bf85f03/node_modules/@webcoder49/code-input/esm/code-input.d.mts:154
     1  node_modules/.pnpm/@webcoder49+code-input@https+++codeload.github.com+WebCoder49+code-input+tar.gz+23b9190_334a95884f3eb8c0b8faf6875bf85f03/node_modules/@webcoder49/code-input/esm/plugins/indent.d.mts:3

or as a screenshot:

image

@WebCoder49

Copy link
Copy Markdown
Owner

I'm pretty sure I fixed both those errors; maybe:

  1. you weren't running on the typescript-tests branch, or
  2. you used generate.mjs when I had only fixed generate.sh (now, I have fixed both of them).

Try these commands in order; my fixes aren't on NPM yet:

cd node_modules/@webcoder49
mv code-input code-input.bak
git clone https://github.com/WebCoder49/code-input code-input
cd code-input
git checkout typescript-tests
cd esm
node generate.mjs # or sh generate.sh
cd ../../../../
tsc

When I've released the fixes to NPM you'll need to run this to revert to the official library:

cd node_modules/@webcoder49
rm -rf code-input
mv code-input.bak code-input
cd ../../

then run NPM update as usual.

@WebCoder49

Copy link
Copy Markdown
Owner

(Sorry for this annoying method; I want to know the fix is correct before I officially release it.)

If it works, get back to me and I should be able to release the library in the next 12 hours.
If it doesn't work, please let me know what the problem is.

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Ugh, my apologies, I had forgotten that step. Indeed it now works...

@WebCoder49

Copy link
Copy Markdown
Owner

Do you mean the compilation now fully works? If so, I can release the fix on NPM now!

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Yes, no tsc errors...

@WebCoder49

WebCoder49 commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Maybe I should wait for you to check the code also runs properly...

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Yeah, sorry, that is also looking good, too!

@WebCoder49

Copy link
Copy Markdown
Owner

That's great. I accidentally put some unrelated breaking changes in the typescript-tests branch, which will not be in the next version (the typescript-tests-v2 branch right now).

There's probably no need to test compilation without them - I don't see how the presence of those breaking changes would cause any difference to the compilation bugs.

@WebCoder49

Copy link
Copy Markdown
Owner

My automated compilation tests work fine with the typescript-tests-v2 branch. Releasing now...

@WebCoder49

Copy link
Copy Markdown
Owner

GitHub, NPM, and the website are all updated to the new release now (and I am going to sleep). Thank you for your time!

@WebCoder49

Copy link
Copy Markdown
Owner

(version 2.8.4)

@brettz9

brettz9 commented Sep 6, 2026

Copy link
Copy Markdown
Author

Thanks--working like a charm both in functionality and types!

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.

2 participants