Comments (12)
Ok, although I'm not sure if that's the best solution, since highlight-words
is broken already now for consumers with TypeScript 4.7+ and this option (TS 5.0 will be coming out soon, so 4.7 is not all that new anymore).
@andrewbranch also mentioned over here that also providing *.d.mts
files is the correct solution for library declaration files:
postcss/postcss#1814 (comment)
from highlight-words.
I think my suggestion above of duplicating the dist/highlight-words.d.ts
file to dist/highlight-words.d.mts
is pretty low effort way of getting a working version published, without having to upgrade highlight-words
to TS 4.7.
from highlight-words.
Workaround
It seems that duplicating dist/highlight-words.d.ts
to dist/highlight-words.d.mts
is one resolution for this issue. I used patch-package
to apply this temporarily for my project until there is a proper fix.
Alternative solution
Maybe using the "exports"
or "types"
fields in package.json
may offer a simpler way of doing it without as much duplication...
from highlight-words.
Hi @karlhorky! Thanks for recreating this :)
It seems that node16
for moduleResolution
is only available from Typescript 4.7 onwards (https://www.typescriptlang.org/tsconfig#moduleResolution). I've not moved highlight-words to that version yet. When I will, this problem should go away (but I will also make sure your issue actually goes away as well).
I'll keep this issue open until then.
from highlight-words.
Still related to Typescript 4.7+, what am I missing? I'm just saying I haven't updated to 4.7+ (and 5.0 is in beta, which I won't migrate to any time soon).
from highlight-words.
What I mean here is that other users may be using versions newer than the version of TypeScript that is used internally in a library. And these newer versions should be supported, even if the library itself does not internally use this newer version yet.
from highlight-words.
Give this a try, if you want: https://www.npmjs.com/package/highlight-words/v/1.2.2-beta.0. The problem is...the tsc error goes away, but you still don't have declarations. It will complain highlightWords
is not callable.
So still working on it, but it's not a priority right now.
from highlight-words.
Oh nice, thanks!
Just took a look, did you mean to also publish the dist/highlight-words.d.mts
file I mentioned above in this version?
I don't see it in the unpkg file explorer for [email protected]
:
from highlight-words.
Nope, but in package.json
, we have the types
prop for exports
:
"exports": {
".": {
"types": "./dist/highlight-words.d.ts", <-----
"require": "./dist/highlight-words.js",
"default": "./dist/highlight-words.mjs"
}
}
which should do the same thing, as far as I understood.
from highlight-words.
It’s not the same thing—see the explanation under “Types are CJS, but implementation is ESM” at https://github.com/arethetypeswrong/arethetypeswrong.github.io.
from highlight-words.
Thanks both! I must admit, I am not familiar with all these since I can't dedicate 100% of my time to it - day job and all you know.
Give [email protected] a try though.
from highlight-words.
[email protected]
seems to work for my project with "module": "node16"
, thanks!
I guess we should leave this issue open until there's a non-beta version published?
from highlight-words.
Related Issues (10)
- ESM Support HOT 14
- Regular expresion in query param? HOT 11
- Invalid query type HOT 2
- This work with IE browser? HOT 1
- Query words with double spaces HOT 4
- Option to ignore diacritics HOT 1
- Option Proposal: `maxLength` HOT 9
- Investigate potential performance issues HOT 3
- New Option: `clipByLength` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highlight-words.