Quasar: Missing typings for icons sets aka "Could not find a declaration file for module 'quasar/icon-set/*'"

Created on 30 Mar 2020  路  6Comments  路  Source: quasarframework/quasar

First of all, thank you for sharing this framework with community. 鉂わ笍

Describe the bug
Could not find a declaration file for module 'quasar/icon-set/svg-mdi-v4'. 'project/node_modules/quasar/icon-set/svg-mdi-v4.js' implicitly has an 'any' type.
Try npm install @types/quasar if it exists or add a new declaration (.d.ts) file containing declare module 'quasar/icon-set/svg-mdi-v4';

Codepen/jsFiddle/Codesandbox (required)
Codepen and jsFiddle are not suitable to reproduce this, or at least I cannot figure it how and Codesandbox (https://codesandbox.quasar.dev) seems to have some problems to start even without any interaction

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.21.1
$ quasar dev
/sandbox/node_modules/.bin/quasar: 1: /sandbox/node_modules/.bin/quasar: os-radio:before: not found
/sandbox/node_modules/.bin/quasar: 2: /sandbox/node_modules/.bin/quasar: content:: not found
/sandbox/node_modules/.bin/quasar: 3: /sandbox/node_modules/.bin/quasar: Syntax error: "}" unexpected

To Reproduce
Steps to reproduce the behavior:

  1. clean typescript Vue CLI project
  2. add quasar in Vue CLI way
https://quasar.dev/options/quasar-icon-sets#Vue-CLI-Way
import iconSet from 'quasar/icon-set/svg-mdi-v4.js'
import { Quasar } from 'quasar'
Vue.use(Quasar, {
  iconSet: iconSet
})
  1. see error in console

Same situation when using svg icons as modules in templates

import { mdiInformation, mdiPlus } from '@quasar/extras/mdi-v4';

Expected behavior
Typings to be provided by framework

Platform (please complete the following information):
OS: MacOS
Node: 12.16.1
NPM: 6.14.3

Temporary solution:
I have created file src/types/shims-mdi.d.ts with following content:

declare module '@quasar/extras/mdi-v4';
declare module 'quasar/icon-set/svg-mdi-v4';

so typescript does not complain.. but autocomplete in editor does not work too

Thanks 馃檹

bug

All 6 comments

Gonna check this next week

@luckylooke I tried to reproduce your issue, but could not.
Which version of quasar and @quasar/extras are you using?

It's true that no autocomplete is provided when importing symbols from @quasar/extras/mdi-v4 tho

Edit: I found how to reproduce it

MDI provides typings for their icons.
https://github.com/Templarian/MaterialDesign-JS/blob/master/mdi.d.ts
Would it be possible to include these in quasar as well?

@luckylooke a PR is on its way, just note that we update only last version of icon sets, so you'll want to use mdi-v5 to get typings when next @quasar/extras is released, mdi-4 won't have them.

@IlCallo ok, thank you all guys 馃憤 馃檹

Fix will be available with "@quasar/extras" v1.6.2.

Was this page helpful?
0 / 5 - 0 ratings