# How do I use `window.moment` without Typescript complaining?
#obsidian/api/faq
---
## Setup
You can [`declare`](https://github.com/liamcain/obsidian-calendar-ui/blob/76febf71efc19f80496de9e9d3341220954c83a7/src/index.ts#L10) it by adding the following to your plugin's main file:
```ts
import type moment from "moment";
declare global {
interface Window {
moment: typeof moment;
}
}
```
You'll also need to add `@types/moment` your `devDependencies` in the `package.json` file.
```bash
// npm
npm install --save --save-exact @types/moment
npm install
// yarn
yarn add --exact @types/moment
yarn
```
Don't worry, the types are just used at compile time and it won't actually add `moment` to your bundle!
## Usage
Once you have that setup, you should be able to access moment.js via `window.moment`.
### Small Gotcha
Importing a default export with `import type` will trigger a warning unless you set `allowSyntheticDefaultImports: true` in your tsconfig.json.
#### Example using the sample-plugin's tsconfig
```json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true, // <-- Add this
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "es6",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"lib": [
"dom",
"es5",
"scripthost",
"es2015"
]
},
"include": [
"**/*.ts"
]
}
```
Not found
This page does not exist