-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Typescript Import issue with NodeNext #1327
Comments
Faced the same issue, but patching vue-i18n's package.json doesn't seem to fix it completely, because now calling useI18n gets inferred as Composer<any, any, any, any, any, any>. I have to specify the return type explicitly. I don't really understand why. Edit: ah, of course, the package.json of @intlify/core-base has to be patched as well, then the types work. I don't really understand why typescript doesn't fallback to the "types" or "typings" field in the root of package.json when it's missing in "exports". |
Another update on this, updating to TS 5 and changing Could not find a declaration file for module 'vue-i18n'. 'C:/path/to/node_modules/.pnpm/vue-i18n@9.2.2_vue@3.2.47/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js' implicitly has an 'any' type.
There are types at 'c:/path/to/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typings.ts(7016) Patching as I mentioned above still seems to fix this for me, |
Evan You is recommending on Twitter that Vue apps set moduleResolution to |
The "types" export needs to come first (for the same reason "default" needs to come last). A better fix would be: "exports": {
".": {
"import": {
"types": "./dist/vue-i18n.d.ts",
"node": "./index.mjs",
"default": "./dist/vue-i18n.esm-bundler.js"
},
"require": {
"types": "./dist/vue-i18n.d.cts", // Note: Different file to the one import points to
"default": "./index.js"
}
},
"./dist/*": "./dist/*",
"./index.mjs": "./index.mjs",
"./package.json": "./package.json"
}, |
|
Thanks @RebeccaStevens, that fixes it for me. I created an MR with your proposed changes: #1388 Until this is merged you can easily fix this for you locally with patch-package like so:
"scripts": {
"postinstall": "npx patch-package"
} And i18n is working with Typescript again nicely 😊 Related: microsoft/TypeScript#52363 |
While the type isn't perfect with Node16 + ESM import, the |
If you will avoid this issue, I would recommend installing the next tag version, (i.e. vue-i18n v9.3). |
tsconfig: disable resolvePackageJsonExports tsconfig: set moduleResolution to "Bundler" vue-i18n does not work with the parameters enabled. intlify/vue-i18n#1327 (comment)
tsconfig: disable resolvePackageJsonExports tsconfig: set moduleResolution to "Bundler" vue-i18n does not work with the parameters enabled. intlify/vue-i18n#1327 (comment)
* Remove old members and add Altium logo * Update partners * Remove old partner logo * Change logo order * Fix partner logos on mobile * Fix homepage * add vscode recommendation * Setup vite + vuejs3 project * Create the default route for / * move img to src/assets/media * config eslint ignore path * install sass and @babel/types * initialise the store in main.ts * clear index.html * create src/styles/settings.scss * force i18n to use the CompositionApi * add the NavbarComponent * add the FooterComponent * fix vue-i18n type's import for typescript 5 tsconfig: disable resolvePackageJsonExports tsconfig: set moduleResolution to "Bundler" vue-i18n does not work with the parameters enabled. intlify/vue-i18n#1327 (comment) * create the JumbotronVideoComponent * Add all extern css and js librairies in index.html * rename CapraLogoWhilte to capraLogoWhite * implement ClientHolder * Populate the Home page with the previous sections * format index.html * format style.min.css * Add Animate on scroll library * rename ClientHolder to SponsorHolderComponent * move .jumbotron styles to the Jumbotron component * remove id="section-featurettes" from HomeView * move more jumbotron styles to Jumbotron component * replace the carousel with a responsive grid * defer script in index.html * fix jumbotron text display * compress video from original files in smaller size * remove unnecessary id on HTMLElement * Rename SponsorHolderComponent to SponsorComponent * Fix the download button for the partenariat * Create the MissionComponent * replace link to /robots with router-link * add more translation * Import Contact and Competition Co-authored-by: Mathieu Salois <mmmhsalois@users.noreply.github.com> * use i18n for prototype_description * reformat i18n trads * update i18n in the mission and homeview * replace a button with an anchor * Allow background image in JumbotronVideoComponent * Set img background in the CompetitionView * update all img's src in CompetitionView * Organise imports * add SponsorItemComponent * add i18n for robocuprescue * move style.min.css into App.vue * rename rrl.JPG to rrl_tmp.jpg * rename rrl_tmp.jpg to rrl.jpg * import bangkok img src to vuejs * import dortmund img src to vuejs * rename comp_team_2019.JPG to comp_team_2019_tmp.jpg * rename comp_team_2019_tmp.jpg to comp_team_2019.jpg * import sydney img src to vuejs * separate competition with comments * add i18n for ContactView.vue * set anchor target to blank in ContactView.vue * i18n competitions * Add PartnersView.vue * Import the partenariat plan in vuejs * i18n discover_our_partnership * Remap the current view in the NavbarComponent * import all partners img in vuejs * set img's alt attributes * set the bg image in PartnersView.vue * set partner anchor target to _blank * Move partners.css into PartnersView.vue * Create RessourcesView.vue * import resources.html into RessourcesView.vue * disable the bibbase script tag * add link to the home page * i18n RessourcesView.vue * replace i18n `made with love` with `made_with_love` * Replace the <script> tag with BibBaseComponent * Create RobotsView.vue * install vue-fullpage.js * move robots.css into RobotsView.vue * Complete RobotsView.vue * Add background image in ContactView.vue * Create TeamView.vue * move avatar.css into TeamView.vue * correct img path in TeamView.vue * rename css' title class to member-title * Create MemberItemComponent.vue * Add the member list in comments * group all members in their category * Update all members * install pinia-plugin-persistedstate * delete old pages * Add Bonzly Noel and William Jarry * remove the dist folder * i18n contact-us * Remove the `EN` button in the navbar * add matomo * fix icon assets * fix i18n for partners and competitions * prefix .env's var with VITE_ * Replace the navbar with a DrawerComponent * use createWebHistory instead of createWebHashHistory * fix url /parners to /partners * fix url /competition to /competitions * Use breakpoints in jumbotron * Fix favicon and page titles * Use router to set title * Move favicon back to assets * Add imports * add type declaration merging for RouteMeta * move the router hook in its own page * Use literal translation for page title * Create deploy workflow * Deploy after merge * Add matomo * Sets the GITHUB_TOKEN permissions * Update program for Nicalas Vigneault * delete 404.html * Update deploy.yml to allow all routes to be served by index.html * Update website URL in README.md https://clubcapra.com -> https://www.clubcapra.com * Delete unused files * Fix heart icon * Remove unused define option from vite.config.ts * Update matomo setup in deploy.yml * added z-index on bg-video * Replace dev by div * fix: toolbar hover color of buttons from red to white * Remove the gap when dropping on robots page * fix: removed absolute to bar, teleport to top when change page Without the scrollBehavior, there were times where you were in the middle of the page when you switched between two, depending on how low you were in previous page * Corrected width to use percents All widths now use their correct percents instead of width: 0pt * Changed static items to vue script Languages used are now in a list and use a script to show progress bars for each * Changed static items to vue script Languages used are now in a list and use a script to show progress bars for each * Bump postcss from 8.4.29 to 8.4.31 (#67) * Bump postcss from 8.4.29 to 8.4.31 Bumps [postcss](https://github.com/postcss/postcss) from 8.4.29 to 8.4.31. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.4.29...8.4.31) --- updated-dependencies: - dependency-name: postcss dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * npm upgrade --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Samuel Lachance <leuchak@slachance.ca> * Fixed Appbar reacts weirdly to resizing the window Fixes #69 Using vue conditionnal visibility and padding * 2022 to 2023 * replace partnership plan for the new version * added and deleted some members * Removed unused image * Added 2 new members and modified Max B's program * Changed Jacob from ELE to LOG * Bump vite from 4.4.11 to 4.4.12 (#76) * Bump vite from 4.4.11 to 4.4.12 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.4.11 to 4.4.12. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v4.4.12/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v4.4.12/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * upgrade package-lock --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Samuel Lachance <leuchak@slachance.ca> * Deleted carlo gavazi and added stelpro as a sponso * Added import of stelpro.png * Named stelpro stelpro. * Added capital to Stelpro * Added Opnor to the list of sponsors and standardized capitalization for Stelpro * removed random space that got into the code * Added Hakko as silver sponsor * Added monday as bronze tier sponsor * Added odrive as bronze tier sponsor * Fixed typo where the sponsor monday appears twice * Changed member names & added new members & removed members * Bump vite from 4.5.1 to 4.5.2 (#80) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.1 to 4.5.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v4.5.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v4.5.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * modified members list * Add 2 tiers for sponsorships (Diamond and Platinum) * temporary removal of the partnetship plan button * changed sponsors tier list according to partnership plan * Added a language chooser in the navbary * Remvoe sponsorship buttons * Change tint values on pictures and videos of markhor * Added linkedin option in contact page * Fix the translation not working on navbar * Fix translating issues and button placement * Hide new tiers for now * Add missing end of line in i18n.ts * Update section compétitions (#82) * added Zwentendorf 2023 section * rearranged comp section + bigger desc fonts * Replace & with & --------- Co-authored-by: Samuel Lachance <leuchak@slachance.ca> * Update ENRICH 2023 photos (zwentendorf) * fix typo compe * Add translation for teams page * Fix typo * Update TeamView.vue * Update TeamView.vue * Add tailwind and clean old code * Add robot landing page animation * Add navbar * Add globe component * Add past competition section * Use videojs for enrich video * Fix competition carousel on mobile * Add team project cards and animations * Add footer and sponsors * Add link to contact footer * Add translations * Revert to youtube iframe * Remove old videos * Remove robots view * Adjust globe sizing * Update footer * Fix footer * Add translations * Add competition tasks * Start team page * Add navbar links * Add competition card translations * Fix sm view * Start new website * Fix partners page * Add publications page * Remove unused pages * Remove unused components * Add locale change * Add page titles * Add new partner plan * Remove unused pictures * Remove unused deps * Fix translation * Add padding bottom to footer * Update members * Move members into data file * Add partners into data file --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Samuel Lachance <leuchak@slachance.ca> Co-authored-by: Mathieu Salois <mmmhsalois@users.noreply.github.com> Co-authored-by: Denis <denis.turk2001@outlook.com> Co-authored-by: Denis <81366683+patates-cipsi418@users.noreply.github.com> Co-authored-by: JocobC <jacobclermont@live.ca> Co-authored-by: JocobC <72584043+JocobC@users.noreply.github.com> Co-authored-by: Raphael Vigneault <43865352+VignRaph@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mmmhsalois <mathieusalois@gmail.com> Co-authored-by: McCaroon <nastyscaper@live.com> Co-authored-by: McCaroon <43826975+McCaroon@users.noreply.github.com> Co-authored-by: Simon St-Andre <simonstandre@gmail.com> Co-authored-by: AntoineMaltais <159335607+AntoineMaltais@users.noreply.github.com> Co-authored-by: Simon St-Andre <50240714+Flip-HH@users.noreply.github.com> Co-authored-by: Nathan Gueissaz-Teufel <45826581+nathan-gt@users.noreply.github.com> Co-authored-by: Nathan <nathan.gt.protic@gmail.com> Co-authored-by: Benoit Malenfant <25072667+benmalenfant@users.noreply.github.com>
Reporting a bug?
When setting
"moduleResolution": "NodeNext",
intsconfig.json
and trying to use this package will result in a error in VSCodeCould not find a declaration file for module 'vue-i18n'
. However everything runs fine, I think this has to do with how exports are being interpretedChanging the
package.json
exports to look like this seems to resolve the issue. Just adding types here as well. Is this a change that would be acceptable?Expected behavior
Package should not show dev time TS errors when using
NodeNext
moduleResolutionReproduction
Quickest reproduction is to just create a TS vue app using Vite, and add
vue-i8n
to the project and update thetsconfig.json
with"moduleResolution": "NodeNext",
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: