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

Unexpected token “export” using babel in docker container with docker-compose and typescript monorepo

I have been struggling with the following issue over the last couple days and can’t seem to track it down. I have a typescript monorepo with a shared package that I am trying to develop in docker using docker-compose. I can run them all directly from my local machine with yarn and everything boots up […]

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

Compiling typescript web worker works from command line but not from gulp

I have a web worker written in typescript. It compiles fine from the command line. However when I try to compile it in Gulp, I get weird type errors: /…/node_modules/@types/hls.js/index.d.ts(357,17): error TS2304: Cannot find name ‘SourceBuffer’. /…/node_modules/@types/hls.js/index.d.ts(1716,27): error TS2304: Cannot find name ‘AudioTrack’. … (more like that) I have no idea where those types come […]

Categories
Development

How to stop TypeScript error ‘Type A has no properties in common with Type B’ when Type B “extends” Type A in some way

(edited Title to make more general) I’m working in a codebase which uses React class components and Typescript everywhere, and I’m trying to implement react-dropzone (a lightweight, simple but effective file-drop component) using the class-based method. The Hooks implementation is cleaner and simpler but I’d prefer to avoid so as to preserve the paradigm maintained […]

Categories
Development

ng build cannot find module

I am trying to locally test 3 node modules by updating the locations they are being pulled from in their package.json files. The modules are sdk, ng-widget-lib, and frontend. ng-widget-lib depends on sdk and frontend depends on ng-widget-lib. I build sdk locally with babel. I’m running verdaccio as a local npm registry. I update ng-widget/package.json […]

Categories
Development

Report typescript errors as warnings in Visual Studio and don’t fail the build

I want to typecheck existing javascript code. To that end, I have specified the following tsconfig. Running tsc results in a couple of hundred errors, which show up in Visual Studio when I do a build. However those errors now also fail the build. As the code is currently functioning, I want to postpone resolving […]

Categories
Development

Angular CLI remove arrow functions?

I am trying to get my code running on IE11, however, I am having issues with arrow functions. I cannot figure out how to remove them from the build and replace them with function() {}. It looks like they were removed from my main.js, but in the vendor.js file, the arrow functions still persist. How […]

Categories
Development

Running an Angular 8 app on Internet Explorer 10, 11

Hello I am having a lot of trouble getting my Angular 8 app to show on Internet Explorer 10 and 11. Currently it just loads a blank white page with an empty component. I have followed giudes online and stackoverflow answers like this: How do I support Internet Explorer in an Angular 8 application? But […]

Categories
Development Plugins XML

Visual Studio Code incorreclty reporting error ‘Cannot find module’ when importing XML file, whilst this error doesn’t appear on build

I’m writing a Typescript testcase, which needs some static xml, loaded from an file which is part of the project. I’m using webpack, in a node/typescript project and am finding that VSC typescript is out of step with the project’s typescript. The line which is causing a problem (from VSC perspective) is this (the testcase […]