Topic: Include typescript setup in docs
Can you include a page in your docs about how to set up typescript correctly?
The way to do it is like this:
import type mdbTypes from '../../../../mdb-js/src/js/mdb.pro.js'
declare const mdb: typeof mdbTypes
const timepicker = new mdb.Timepicker(element, mdbOptions)
Then when you try to use timepicker in vscode, it will autocomplete all the methods, like timepicker.dispose().
This works because I have a script tag with src="mdb.min.js" in my html. The "declare const mdb" indicates that the mdb variable is globally available from that script tag so we don't have to import. The import type makes sure the mdb stuff is not included by typescript when you compile.
Took me a while to figure out, would be nice if there was a page in the docs for this for other people.
Kamila Pieńkowska staff answered 4 months ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB Standard
- MDB Version: -
- Device:
- Browser:
- OS:
- Provided sample code: No
- Provided link: No