Comments (5)
Hi, that's indeed a problem!
What version of TypeScript are you using? Is the library actually impossible to import or is the problem only related to typing information?
from smol-toml.
Actually, I've just tried and I seem to be able to reproduce this using stock TS config. By specifying moduleResolution
to node16
(or nodenext
), TypeScript will actually resolve the types using my package.json's exports
specification solving this issue.
This is not ideal, and considering I have a way to avoid this issue completely I'll change that in a future release. In the meantime, using the workaround described above should work.
from smol-toml.
Sorry for my late response and thanks for your moduleResolution
-tip!
from smol-toml.
You need to add "types": "./dist/index.d.ts"
and "main": "./dist/index.js"
to the package.json
(Reference).
from smol-toml.
TypeScript added support for NodeJS's exports
field in TypeScript 4.7 and does correctly look up the types
specified in this. main
is unrelated to TypeScript and is useless in this context.
Realistically, failure to resolve the package's types is an indication of either an outdated TypeScript installation, or an improper configuration as I described above. While adding types
at the root of the package is currently possible, it is only "accidental" and does not fully reflect the true Node Resolve Algorithm used.
References:
- https://github.com/microsoft/TypeScript/blob/88cb76d314a93937ce8d9543114ccbad993be6d1/src/compiler/moduleSpecifiers.ts#L963-L982
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#resolvepackagejsonexports
- https://nodejs.org/api/packages.html#exports
- https://nodejs.org/api/esm.html#resolution-algorithm-specification, PACKAGE_RESOLVE step 11-5
from smol-toml.
Related Issues (11)
- Encode support HOT 4
- Explicit type for parse HOT 5
- Automated Testing and Deployment HOT 1
- Failing Valid Compliance Tests HOT 1
- Export the `parseKey` function for parse/validate keys outside the parse process?
- Is it possible to specify style? HOT 4
- Stringify on array of objects runs into error HOT 2
- Preserve fields with empty array values when converting json to toml format? HOT 2
- [Feature Request] Get the comments of `.toml` HOT 1
- Warning error in Angular 17 saying it is not ES6 modules . HOT 2
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 smol-toml.