I need a full example on how to use Tippy.js
with Typescript
. I see in all examples lines similar to
import tippy, {Tippy, Props, Plugin, LifecycleHooks} from 'tippy.js';
tippy('[data-tippy-content]');
However, I get the error message
This expression is not callable.
Type 'typeof import("/Users/***/node_modules/tippy.js/index")' has no call signatures.ts(2349)
That seems to make sense, as the type definition has these two lines:
declare const tippy: Tippy;
// other stuff
export default tippy;
Tippy itself is an interface, so the examples seem outdated or based on yet other libraries.
My tsconfig.json is as following:
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"module": "ES2022",
"rootDir": "./src",
"moduleResolution": "Node16",
"paths": {
"/*.ts": [
"./src/*.ts"
],
"/*.js": [
"./src/*.js"
],
"/*": [
"./*.ts",
"./*.js",
"./*"
]
},
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"sourceMap": true,
"outDir": "./types",
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"allowUnusedLabels": false,
"plugins": [
{
"name": "ts-lit-plugin"
}
]
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}