Categories
Development

VSCode ESLint howto fix parsing error: ‘import’ and ‘export’ may only appear at the top level

NOTE: The Code is working, only ESLint is giving me an error which i want to fix!! When doing a dynamic import: if (true) import x from ‘y’; //Parsing error: ‘import’ and ‘export’ may only appear at the top level my .eslintrc { “root”: true, “extends”: “eslint:recommended”, “env”: { “es6”: true, “node”: true, “browser”: true […]

Categories
Development

TypeScript: Property ‘X’ does not exist on ‘Window & typeof globalThis’: suggested solution using ‘declare global’ gives me error

Edit: This is an ESlint problem. I’ve included my ESLint setup at the end of this post. I’m fairly new to TypeScript — I have been refactoring someone else’s React code, moving it to TypeScript for a work project when I ran into this line const memoryOptionsResponse = window.webchatMethods.getMemory(chatId); TypeScript complains about ‘window.webchat’, saying Property […]

Categories
Development Plugins

eslint not linting though server is running

I downloaded a frontend template online and yarn installed all packages and an .eslint.json file does exist and the extension is installed in Visual Studio Code but it does not show any linting errors. Here is my .eslint.json file { “parser”: “babel-eslint”, “parserOptions”: { “ecmaVersion”: 6, “sourceType”: “module”, “ecmaFeatures”: { “jsx”: true, “modules”: true, “experimentalObjectRestSpread”: […]

Categories
Development

“Navbar refers to a value, but is being used as a type here” when trying to render a shallow copy of my component when testing

I am trying to write a test to my React component, using TypeScript, Jest as my test runner and Enzyme for testing my React components. Whenever I pass my component into the shallow Enzyme function, I get the ts error “‘Navbar’ refers to a value, but is being used as a type here.”, and underneath […]