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

Vue declaration files endings -- .vue.d.ts vs. .d.ts #224

Closed
m4rvr opened this issue Apr 2, 2020 · 13 comments · Fixed by #336
Closed

Vue declaration files endings -- .vue.d.ts vs. .d.ts #224

m4rvr opened this issue Apr 2, 2020 · 13 comments · Fixed by #336
Assignees
Labels
kind: discussion Discussion on changes to make kind: support Asking for support with something or a specific use case problem: removed issue template OP removed the issue template without good cause scope: integration Related to an integration, not necessarily to core (but could influence core) scope: vue Related to integration with Vue (rollup-plugin-vue is long archived), not core solution: invalid This doesn't seem right solution: reverted This change was reverted after being determined to contain a regression solution: Vue behavior This is Vue's behavior as well, so this is not a bug with this plugin

Comments

@m4rvr
Copy link

m4rvr commented Apr 2, 2020

What happens and why it is wrong

Building works fine but the generated declaration file from a SFC for example MyComponent.vue is named as MyComponent.vue.d.ts which breaks my imports (also generates like that without importing another SFC).

Renaming the file to MyComponent.d.ts works and the errors are gone.

Environment

I'm using this plugin together with rollup-plugin-vue and rollup-plugin-babel. I also have @rollup/plugin-commonjs & @rollup/plugin-node-resolve if that does matter.

Could that be a configuration problem with my tsconfig.json? I will try to add the configs if needed.

Versions

  • typescript: 3.8.3
  • rollup: 2.3.2
  • rollup-plugin-typescript2: 0.27.0
@ezolenko ezolenko added the kind: bug Something isn't working properly label Apr 6, 2020
@ezolenko
Copy link
Owner

ezolenko commented Apr 6, 2020

Could you check if bug/224 branch works for you? https://github.com/ezolenko/rollup-plugin-typescript2/tree/bug/224

@joakimbugge
Copy link

joakimbugge commented Jun 11, 2020

I just wanted to let you know that I have basically the same setup and I tested your branch. A single dot is still remaining in the file name, e.g. Alert.vue -> Alert..d.ts.

@Mister-Hope
Copy link

Any progress on this?

@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label Apr 27, 2022
@agilgur5 agilgur5 changed the title Vue declaration files have wrong file endings .vue.d.ts Vue declaration files have wrong file endings -- .vue.d.ts instead of .d.ts May 31, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented May 31, 2022

Wrote up a PR #336 to fix this, building on top of ezolenko's earlier branch and incorporating feedback from above on it.

Just noting that the root cause here is that the rollup-plugin-vue maintainers themselves said to name it as .vue.d.ts in #97 (comment) . Given that this is an integration specifically for that plugin, don't think anyone wouldn't have thought that their suggestion could cause some issues like this, but we all make mistakes 😅

@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 2, 2022

Released in 0.32.0

@agilgur5 agilgur5 self-assigned this Jun 2, 2022
@agilgur5 agilgur5 added the problem: removed issue template OP removed the issue template without good cause label Jul 9, 2022
@andrew0
Copy link

andrew0 commented Jul 24, 2022

@m4rvr Can you recall how you were importing your Vue components when you originally ran into this issue? i.e. were you doing import MyComponent from './MyComponent.vue' or import MyComponent from './MyComponent'? According to the Vue team, it is not recommended to auto-resolve the .vue extension, and they won't support extensionless SFC imports going forward.

As far as I can tell, this issue was only occurring if you were importing the component without the extension. But now that this plugin is stripping the .vue extension from the .d.ts files, import MyComponent from './MyComponent.vue' no longer works.

@agilgur5
Copy link
Collaborator

agilgur5 commented Jul 29, 2022

@Mister-Hope @joakimbugge @dhruvkb @alexancheck would any of you be able to provide input or reproductions on the above? (all of you commented on or upvoted this issue)

According to the Vue team, it is not recommended to auto-resolve the .vue extension, and they won't support extensionless SFC imports going forward.

As far as I can tell, this issue was only occurring if you were importing the component without the extension. But now that this plugin is stripping the .vue extension from the .d.ts files, import MyComponent from './MyComponent.vue' no longer works.

Given the above and that vue-tsc produces .vue.d.ts files (see also my repro in #336 (comment)), it is likely that we will revert the change in #336 that was requested by this issue.

If you believe it should be .d.ts and not .vue.d.ts, please explain why with examples.
As far as I can tell (and I am not a Vue user), per the above evidence, .vue.d.ts seems to be the more accurate and supported extension (both officially and community supported).

@joakimbugge
Copy link

I can't find whatever project I was working on when I commented on this issue, but I did find another project from around that same time. In the project I'm importing components with file extension (import MyComponent from './MyComponent.vue'), the generated type file is named MyComponent.vue.d.ts and all imports work fine in index.d.ts.

I don't think it ever hit me that the missing file extension was the culprit, but that probably was the reason for it not working. I was young and dumb and hated file extensions. It was a phase.

This change should probably be reverted.

@dhruvkb
Copy link

dhruvkb commented Jul 30, 2022

In the project where I encountered this issue, I ended up not using rollup-plugin-typescript2 and switched to vue-tsc. Sorry I can't reproduce this anymore.

@agilgur5
Copy link
Collaborator

agilgur5 commented Jul 31, 2022

@dhruvkb in the vue-tsc project, you're also using .vue.d.ts declaration files, right?
(as in, MyComponent.vue.d.ts, not MyComponent.d.ts)

That seems to be what vue-tsc outputs, per my above comment, so confirming that would still be helpful for alignment! Appreciate the response 🙂

@dhruvkb
Copy link

dhruvkb commented Jul 31, 2022

Yes vue-tsc also outputs .vue.d.ts files and they are resolved properly when importing components with the .vue extension. I think adding the .vue before .d.ts is a good idea. I'll take my 👍 back.

@agilgur5 agilgur5 changed the title Vue declaration files have wrong file endings -- .vue.d.ts instead of .d.ts Vue declaration files endings -- .vue.d.ts vs. .d.ts Aug 3, 2022
@agilgur5
Copy link
Collaborator

So not everyone has responded unfortunately, but I think we have more than enough tie-breaking votes and evidence to go forward with reverting this. Will have a PR out for that shortly, though it may only release during the next breaking release.

As an aside, note that this may very well be impacted by recent upstream issues with newer node16+ moduleResolution such as microsoft/TypeScript#50133 and microsoft/TypeScript#49970

@agilgur5 agilgur5 added the kind: discussion Discussion on changes to make label Aug 17, 2022
@agilgur5 agilgur5 added solution: invalid This doesn't seem right solution: intended behavior This is not a bug and is expected behavior kind: support Asking for support with something or a specific use case and removed kind: bug Something isn't working properly solution: intended behavior This is not a bug and is expected behavior labels Aug 18, 2022
@agilgur5 agilgur5 added solution: Vue behavior This is Vue's behavior as well, so this is not a bug with this plugin solution: reverted This change was reverted after being determined to contain a regression priority: in progress labels Aug 18, 2022
@agilgur5
Copy link
Collaborator

Reverted the change and went back to .vue.d.ts in #410, which has been released in 0.33.0

@agilgur5 agilgur5 added the scope: vue Related to integration with Vue (rollup-plugin-vue is long archived), not core label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: discussion Discussion on changes to make kind: support Asking for support with something or a specific use case problem: removed issue template OP removed the issue template without good cause scope: integration Related to an integration, not necessarily to core (but could influence core) scope: vue Related to integration with Vue (rollup-plugin-vue is long archived), not core solution: invalid This doesn't seem right solution: reverted This change was reverted after being determined to contain a regression solution: Vue behavior This is Vue's behavior as well, so this is not a bug with this plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants