vuetifyjs / vuetify

🐉 Vue Component Framework
https://vuetifyjs.com
MIT License
39.85k stars 6.97k forks source link

[Bug Report][3.0.0-alpha.8] Missing type declarations for composables and iconsets #13901

Closed glen-84 closed 3 years ago

glen-84 commented 3 years ago

Environment

Vuetify Version: 3.0.0-alpha.8 Vue Version: 3.1.4 Browsers: Chrome 91.0.4472.124 OS: Windows 10

Steps to reproduce

Try to use types like:

Expected Behavior

Types to exist.

Actual Behavior

They don't.

Reproduction Link

n/a

Other comments

It's really quite difficult working with all these missing types. 🙂

glen-84 commented 3 years ago

@KaelWD Can I send a PR for this?

KaelWD commented 3 years ago

If you have an idea for it sure, idk how I want to handle these yet.

glen-84 commented 3 years ago

In the docs, icon and theme stuff is exported via vuetify, but useDisplay is exported via vuetify/lib/composables/display.

Exporting additional things via vuetify is simple, but exporting via vuetify/lib/composables/* in your current system appears to require additional createConfig calls in rollup.config.js (which doesn't appear to support globbing).

I had started with:

entry.ts

export * from './components'
+export * from './composables'
export * from './directives'
export * from './framework'

composables/index.ts

export { useDisplay } from './display'
export { IconAliases, IconProps, IconSet } from './icons'
export { ThemeDefinition } from './theme'

rollup.config.js

export default [
  createConfig('entry.d.ts', 'lib/entry.d.ts'),
  createConfig('framework.d.ts', 'lib/framework.d.ts'),
  createConfig('entry-bundler.d.ts', 'dist/vuetify.d.ts'),
  createConfig('components/index.d.ts', 'lib/components/index.d.ts'),
  createConfig('directives/index.d.ts', 'lib/directives/index.d.ts'),
+ createConfig('iconsets/mdi-svg.d.ts', 'lib/iconsets/mdi-svg.d.ts'), // +5 more for the other icon sets.
]

... but then I noticed that useDisplay wasn't exported directly from vuetify in the docs, so a decision would need to be made in that regard.

The rollup configuration could get a little bit out-of-control if everything has to be listed manually, especially for things like icon sets where the same names (aliases, etc.) are being exported so you can't just export from an index (unless you rename the exports so that you can do something like import { mdi, mdiAliases, mdiSvg, mdiSvgAliases } from 'vuetify/iconsets').

glen-84 commented 3 years ago

@KaelWD,

I installed @microsoft/api-extractor@7.18.4, and added your npm script:

"build:types": "rimraf types-temp && tsc --pretty --emitDeclarationOnly -p tsconfig.dist.json && api-extractor run --local --verbose && rimraf types-temp"

It runs without errors, and the only warnings are things like:

Warning: src/framework.ts:22:1 - (ae-missing-release-tag) "createVuetify" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)

... which should be easy to fix by just adding /** @public */ (or @alpha), or by removing the export of symbols that should not be exported.

I made no other changes to the code. Were you seeing other errors? If so, does that mean that everything is fixed, and this is ready to be used?

The current warnings ``` Warning: src/components/VCode/index.ts:5:14 - (ae-missing-release-tag) "VCode" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/VKbd/index.ts:5:14 - (ae-missing-release-tag) "VKbd" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:9:14 - (ae-missing-release-tag) "VCarouselTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:10:14 - (ae-missing-release-tag) "VCarouselReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:11:14 - (ae-missing-release-tag) "VTabTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:12:14 - (ae-missing-release-tag) "VTabReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:13:14 - (ae-missing-release-tag) "VMenuTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:14:14 - (ae-missing-release-tag) "VFabTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:17:14 - (ae-missing-release-tag) "VDialogBottomTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:18:14 - (ae-missing-release-tag) "VDialogTopTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:19:14 - (ae-missing-release-tag) "VFadeTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:20:14 - (ae-missing-release-tag) "VScaleTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:21:14 - (ae-missing-release-tag) "VScrollXTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:22:14 - (ae-missing-release-tag) "VScrollXReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:23:14 - (ae-missing-release-tag) "VScrollYTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:24:14 - (ae-missing-release-tag) "VScrollYReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:25:14 - (ae-missing-release-tag) "VSlideXTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:26:14 - (ae-missing-release-tag) "VSlideXReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:27:14 - (ae-missing-release-tag) "VSlideYTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:28:14 - (ae-missing-release-tag) "VSlideYReverseTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:31:14 - (ae-missing-release-tag) "VExpandTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/components/transitions/index.ts:32:14 - (ae-missing-release-tag) "VExpandXTransition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/click-outside/index.ts:69:14 - (ae-missing-release-tag) "ClickOutside" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/intersect/index.ts:74:14 - (ae-missing-release-tag) "Intersect" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/resize/index.ts:36:14 - (ae-missing-release-tag) "Resize" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/ripple/index.ts:343:14 - (ae-missing-release-tag) "Ripple" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/scroll/index.ts:53:14 - (ae-missing-release-tag) "Scroll" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/directives/touch/index.ts:149:14 - (ae-missing-release-tag) "Touch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/framework.ts:22:1 - (ae-missing-release-tag) "VuetifyOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) Warning: src/framework.ts:32:14 - (ae-missing-release-tag) "createVuetify" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) ```
glen-84 commented 3 years ago

Could this be an issue, or are you okay with exporting everything from a single entry file?

If you are, then I guess it answers the question about:

import { useDisplay } from 'vuetify/lib/composables/display'

vs

import { useDisplay } from 'vuetify'

... but it would probably require exporting unique names (f.e. in the icon case, where you have multiple aliases, etc.).

KaelWD commented 3 years ago

14099