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: update default vue 3 typescript shim #6023

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

fix: update default vue 3 typescript shim #6023

wants to merge 2 commits into from

Conversation

jeneser
Copy link
Contributor

@jeneser jeneser commented Oct 28, 2020

#6021 eslint warns about "unsafe any" in default shim when formatting.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

using unknown / never is good enough, or using any with a disable comment explaining why it's safe is a much better alternative. typescript-eslint/typescript-eslint#1071 (comment)

@haoqunjiang
Copy link
Member

@cexbrayat @pikax I'm no expert in TypeScript so I'm not sure which is the better way to shim .vue type, using unknown or any with an eslint-disable-line comment. Do you have any opinion on this?

From what I understand, unknown is not assignable to any other type, so seems using the unknown type may break some real-world use cases? I haven't encountered any but I'm concerned about that.

@cexbrayat
Copy link
Member

I think unknown is going to be painful, as wrapper.vm.something will be typed as never in unit tests, forcing developers to cast vm themselves every time. I do agree that any is not ideal, but it allows to write unit tests without too much trouble. I sadly don't think we can do better right now.

2 possible ways to deal with the issue with eslint:

  • add a simple eslint-disable-next-line no-any in the shim
  • or exclude d.ts files from eslint (my favorite, as it makes no real sense for eslint to analyze the shim)

@bodograumann
Copy link
Contributor

The rule could also be @typescript-eslint/no-explicit-any.

haoqunjiang added a commit that referenced this pull request Dec 14, 2020
See #6023

It's not the ideal solution, though.

In the long run we should have the shim built-in (either in this plugin
or in the `vue-loader` package), for which ESLint rules should be
properly applied, and the user can simply import that shim module.
Copy link

@ziazon ziazon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider changing the shim to:

declare module '*.vue' {
  import type { DefineComponent } from 'vue';
  const component: DefineComponent<
    Record<string, unknown>,
    Record<string, unknown>,
    unknown
  >;
  export default component;
}

haoqunjiang added a commit that referenced this pull request Jan 6, 2021
See #6023

It's not the ideal solution, though.

In the long run we should have the shim built-in (either in this plugin
or in the `vue-loader` package), for which ESLint rules should be
properly applied, and the user can simply import that shim module.
@falstack falstack mentioned this pull request Jun 29, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants