#Type error when importing prism manually

14 messages · Page 1 of 1 (latest)

marble otter
#
import React from 'react'
import { Container, Button } from '@mantine/core'
// import { Prism } from '@mantine/prism'
import Prism from 'prism-react-renderer/prism';
#

Could not find a declaration file for module 'prism-react-renderer/prism'. 's:/_codeProjects/ulc-app/node_modules/prism-react-renderer/prism/index.cjs.js' implicitly has an 'any' type.ts(7016)

#

adding ```ts
(typeof global !== 'undefined' ? global : window).Prism = Prism;

gives another error
```Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.ts(7017)```
quick tendon
marble otter
#

sorry im new to ts, what exactly should I do with those

#

I added the ignore

//@ts-ignore
import Prism from 'prism-react-renderer/prism';
#

that error has been resolved, just need to figure out why the import for the lagnuage isn't working now : )

#

Ah, because prismjs is a separate package from prism-react-renderer haha

#

for some reason

import Prism from 'prism-react-renderer/prism';

require('prismjs/components/prism-lua');```
results
```Uncaught ReferenceError: Prism is not defined - prism-lua.js:1```
#

it doesn't even work with that import method when trying to use one of the included languages (json)

#

I guess this line is the fix for that?

(typeof global !== "undefined" ? global : window).Prism = Prism;```
but this just gives me