X Tutup
The Wayback Machine - https://web.archive.org/web/20201125094410/https://github.com/SheetJS/sheetjs/pull/2184
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

Fix Types not Resolving in Node ESModule projects #2184

Open
wants to merge 1 commit into
base: master
from

Conversation

@josh-hemphill
Copy link

@josh-hemphill josh-hemphill commented Nov 24, 2020

EsModule imports do not automatically resolve index files of directories, so the "types": "types" does not resolve to the types/index.d.ts as was intended. If it doesn't break anything, it should be changed to "types": "types/index.d.ts".
According to the Typescript Spec, the types/typings field should be a file, not a directory.

@josh-hemphill josh-hemphill changed the title Types not resolvable in Node ESModule projects Fix Types not Resolving in Node ESModule projects Nov 24, 2020
@josh-hemphill josh-hemphill deleted the josh-hemphill:patch-1 branch Nov 24, 2020
@SheetJSDev
Copy link
Contributor

@SheetJSDev SheetJSDev commented Nov 24, 2020

Does it actually require the filename? If so, how was this even working in the first place?

@josh-hemphill josh-hemphill restored the josh-hemphill:patch-1 branch Nov 24, 2020
@josh-hemphill josh-hemphill reopened this Nov 24, 2020
@josh-hemphill
Copy link
Author

@josh-hemphill josh-hemphill commented Nov 24, 2020

Sorry, I though the problem might just be my configuration, but It's gone full circle now, and nothing I've been able to do has gotten me intellisense/type completion.
If I set baseUrl then VSCode gives me File "[Absolute Path]/node_modules/xlsx/types" not found in my jsconfig file.
If I do /// <reference path="../../../node_modules/xlsx/types/index.d.ts" /> in the file I need it, I do get the type information.
The reason this probably only came up now is the native ES Module support in Node; with the new ES Module support, if you make your project an ES Module project, then there won't be any /index.* inference since ES Imports require absolute paths when not being compiled by typescript.
So it probably only comes up with ES Module JS projects only for type information, but it might also come up more critically if typescript starts using Node's native ES module resolution after sourcemaps and import/export configs become standardized probably in Node v16.

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.
X Tutup