I'm having trouble importing choices.js using the "import" command:
import Choices from 'choices.js';
TS2307: Cannot find module 'choices.js'
The following attempts didn't work either:
import Choices from '../../node_modules/choices.js/public/assets/scripts/choices.js';
TS7016: Could not find a declaration file for module '../../node_modules/choices.j
s/public/assets/scripts/choices.js'. '/project/node_modules/choices.js/public/assets/scr
ipts/choices.js' implicitly has an 'any' type.
And this one as well:
/// <reference path="../../node_modules/choices.js/types/index.d.ts" />
import Choices from '../../node_modules/choices.js/public/assets/scripts/choices.js';
TS7016: Could not find a declaration file for module '../../node_modules/choices.j
s/public/assets/scripts/choices.js'. '/project/node_modules/choices.js/public/assets/scr
ipts/choices.js' implicitly has an 'any' type.
Only this command seems to be working:
const Choices = require(`choices.js`);
Unlike with loadash, I didn't encounter any issues and it imported smoothly:
yarn add -D lodash @types/lodash
import lodash from 'lodash';
I must be missing something here, but I can't figure out where I'm going wrong and how to fix it. :(
Update: The es6 import only works for me if I change noImplicitAny from true to false in tsconfig.json and use the absolute path to the js file in this library in my .ts file:
import * as Choices from '../../node_modules/choices.js/public/assets/scripts/choices.js';
Seems like there's an issue with types in my version...