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, […]

Categories
Mastering Development

while ionic serve I’m getting this error “typescript: node_modules/@types/node/worker_threads.d.ts, line: 8 ‘=’ expected. “

My ionic info: cli packages: (/usr/local/lib/node_modules) @ionic/cli-utils : 1.9.0 ionic (Ionic CLI) : 3.9.0 global packages: Cordova CLI : 9.0.0 (cordova-lib@9.0.1) local packages: @ionic/app-scripts : 3.2.4 Cordova Platforms : android 7.1.4 browser 5.0.3 Ionic Framework : ionic-angular 3.9.2 System: Android SDK Tools : 26.1.1 ios-deploy : 1.10.0 Node : v10.13.0 npm : 6.4.1 OS : […]

Categories
Mastering Development

Issue trying to setup jest: application code compiles fine but test code doesn’t

I am trying to migrate to jest and I am facing typescript issues… I have 3 tsconfig files: tsconfig.json (base config) tsconfig.lib.json (application config) tsconfig.jest-spec.json (jest-dedicated test config) Please note that there are also karma/jasmine dedicated tsconfig files but those are irrelevant. I have separated the jest tests from the karma ones. tsconfig.json { "compileOnSave": […]

Categories
Mastering Development

tsconfig path cannot be found

I am working on a nodejs app and I want to configure my path in tsconfig.json but I am having issues with the path configuration I keep getting an error Error: Cannot find module ‘@environment’. what could be the issue? tsconfig { “compilerOptions”: { “resolveJsonModule” : true, “target”: “es6”, “module”: “commonjs” , “lib”: [ “dom”, […]

Categories
Mastering Development

TypeScript not finding variable declared in type declaration if I import a file

I made a very simple library which contains a .d.ts (source) which has the following structure (I omit the details because the file works fine, it likely is a config issue in my project): // Some helper types and interfaces type TranslationFunction = /* … */; export { TranslationFunction }; Then, I do npm i […]

Categories
Mastering Development

Angular library on ng build files are not included on dist folder

I have a library create with angular 9 with a project structure like below When I build the library ng build falcon-core the view-models files are not included in the dist folder I didn’t find any settings related to the files structure in the tsconfig.lib.ts { “extends”: “../../tsconfig.json”, “compilerOptions”: { “outDir”: “../../out-tsc/lib”, “target”: “es2015”, “declaration”: […]

Categories
Development

Why is this React Typescript app throwing errors?

I just created a new React app using npx create-react-app my-app –template typescript and it was working fine until I changed my component to from a stateless one to a stateful one. The error: JSX element type ‘App’ is not a constructor function for JSX elements. TS2605 3 | import App from “./App”; 4 | […]

Categories
Development

Access a class orientated JavaScript library in Typescript

I’m currently working with a project that has 3 pre-made libraries written in JavaScript. The 3 libraries in question where originally written in Typescript then transpiled to es5 javascript for use with other javascript files. To use them in other JS files they are used as follows: <script src=”libraryone.js”></script> <script> var myLibOne = new LibraryOne(); […]

Categories
Development JSON

VSCode Extension webview load json file problem

I am trying to build a project where I have one json file that I have to parse in my main file. But I cannot include it in main file. In terminal there is no error both for main.ts and main.js. Webview panel is showing the content from the html but nothing from the main […]

Categories
Development

Jest & React & Typescript & React-Testing-Library error

I have a React/NextJS project setup using Typescript and am adding unit testing with Jest and React Testing Library. A unit test for my component looks like this: import React from ‘react’; import ‘@testing-library/jest-dom/extend-expect’; import { render } from ‘@testing-library/react’; import AppLayout from ‘.’; describe(‘<AppLayout>’, () => { it(‘renders children’, () => { const children […]