Categories
Mastering Development

Jest withTypeScript syntaxerror unexpected token, expected “;”

I’ve been trying to setup jest for use with typescript and I’ve tried a bunch of fixes with no luck. I’m getting the error SyntaxError: Unexpected token, expected ";", I think the config isn’t supporting typescript code: https://i.stack.imgur.com/iGBCa.png If anybody has any suggestions I’d be very grateful! Here’s my package.json: "jest": { "preset": "ts-jest", "testEnvironment": […]

Categories
Mastering Development

Cannot find ‘File’ type definitions Papaparse @types/papaparse

TS cannot find the File interface within the "@types/papaparse" module. I’d imagine that File is a Node type so I’m wondering if it’s maybe a TS setup issue. /node_modules/@types/papaparse/index.d.ts (23,25): Cannot find name ‘File’. /node_modules/@types/papaparse/index.d.ts (118,47): Cannot find name ‘File’. /node_modules/@types/papaparse/index.d.ts (119,38): Cannot find name ‘File’. /node_modules/@types/papaparse/index.d.ts /// <reference types="node" /> export as namespace Papa; […]

Categories
Mastering Development

IE11 Blank Page with React, Typescript, Babel, and Webpack

I have a React application written in Typescript with Babel and Webpack. It loads fine in Firefox and Chrome, but loads a blank page in Internet Explorer 11. I am new to this project with relatively low experience with React/Babel/WebPack/Typescript. I need to make the app work with IE11. I’ve spent a couple days learning […]

Categories
Mastering Development

‘ReactPlayer’ cannot be used as a JSX component

I attempt to use react-player for my React project. I’m using Typescript. I received the following error when I build it: ‘ReactPlayer’ cannot be used as a JSX component. Its instance type ‘ReactPlayer’ is not a valid JSX element. The types returned by ‘render()’ are incompatible between these types. Type ‘ReactNode’ is not assignable to […]

Categories
Mastering Development

CRA error – Cannot add property paths, object is not extensible

[debug: true] PS C:\data\test\todo> npm start > todo@0.1.0 start C:\data\test\todo > craco start craco: *** Cannot find ESLint loader (eslint-loader). *** Initial options: { "source": "tsconfig", "baseUrl": "./src", "tsConfigPath": "./tsconfig.extend.json", "debug": true } Normalized options: { "source": "tsconfig", "baseUrl": "./src", "tsConfigPath": "./tsconfig.extend.json", "debug": true } Aliases: { "@root": "C:\\data\\test\\todo\\src" } Webpack Config: { "react-native": "react-native-web", […]

Categories
Mastering Development

Mocha Test can’t find npm module

I have tests in src/test/server-new that exercise code in src/server-new the root (./) of my app which is a mono repo, I have a package.json that has these dependencies installed: "express-graphql": "^0.11.0", "graphql": "^15.3.0", these are used in src/server-new/api.js as it imports and uses those npm modules. I have a test that imports src/server-new/api.ts: src/test/server-new/my.test.spec.ts […]

Categories
Mastering Development

How to enable @ experimentalDecorators in next.config.js or babelrc

Hi if someone would help me, I wanna use @Decorators on my nextjs app, but I get the following error. Hope someone knows what Im doin wrong Error message: Syntax error: Support for the experimental syntax ‘decorators-legacy’ isn’t currently enabled: I’m trying to use typeorm / type-graphql to generate my backend in an app subfolder. […]

Categories
Mastering Development

Webpack – import const from .d.ts file not working – Can’t resolve ‘@nuvolo/servicenow-types/server/GlideRecord’

I’m doing this: import { GlideRecord } from "@nuvolo/servicenow-types/server/GlideRecord"; I have a file node_modules/@nuvolo/servicenow-types/server/GlideRecord.d.ts It contains: … type GlideRecordConstructor = { new <T>(table: string): GlideRecord<T> }; type GlideRecord<T> = GlideRecordBase<T> & T; declare const GlideRecord: GlideRecordConstructor; export { GlideRecord }; If I run tsc it works, no errors Webpack says: Module not found: Error: Can’t […]

Categories
Mastering Development

Unable to load preload script – Electron.js Ubuntu 18.04.4

I’m trying to understand how to effectively load the proload.js file in electron: Version "electron": "^9.1.2", Version "electron-builder": "^22.8.0", In background.js I put webPreferences: { nodeIntegration: false, contextIsolation: true, //preload: path.join(app.getAppPath(), "preload.js"), preload: path.join(__dirname, "./preload.js"), }, preload.js and background.js are in the same folder: src folder. this is my preload.js : const { contextBridge, ipcRenderer […]

Categories
Mastering Development

Is it possible to configure wdio to make use of different tsconfig files?

I’m trying to get wdio setup to run our React TypeScript app. The problem is that it only works if I modify the tsconfig.json file itself to make use of the required types, change module to commonjs and set isolatedModules to false: { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, […]