Apologies for this odd question, but I'm having a strange issue that I can't seem to pinpoint.
I am trying to create a module for a library I have installed called 'scroll-to'. However, when I compile my code to JavaScript and hover over the import, it says "Could not find a declaration file for module 'scroll-to'." along with some other lines.
Here is my 'scroll-to.d.ts':
declare module "scroll-to" {
const scrollTo: (x: number, y: number, options: {
ease?: string,
duration?: number
}) => void
export default scrollTo
}
'app.ts':
import scrollTo from 'scroll-to'
scrollTo(500, 1200, {
ease: 'out-bounce',
duration: 1500
});
'app.js' in '/dist':
import scrollTo from 'scroll-to';
scrollTo(500, 1200, {
ease: 'out-bounce',
duration: 1500
});
'tsconfig.json':
{
"compilerOptions": {
"outDir": "dist",
"target": "ES2021",
"noEmitOnError": true,
"strict": true,
"declaration": true,
"moduleResolution": "Node",
},
"files": [
"src/app.ts"
],
"include": [
"src/types/**/*"
]
}
'package.json':
{
"name": "ts",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^5.1.6"
},
"dependencies": {
"scroll-to": "^0.0.2"
}
}
Additionally, I have imported my script with a type="module" in the HTML. I'm at a loss as to what could be going wrong.