Categories
Mastering Development

Chrome extension “‘chrome’ is not defined” with typescript

I have a barebones chrome extension that’s running on my local computer. All the files are compiling correctly from .ts to .js and working as expected. However, in my src/background.ts once I dropped in: chrome.extension.onMessage.addListener(() => { // do something }); … I immediately got the error: ‘chrome’ is not defined. I’ve installed @types/chrome to […]

Categories
Mastering Development

Angular 10: Path Mapping shows error in VSCode when import

So I updated a project that was in Angular 8.2 (a project template) to version 10 and followed the instructions from https://update.angular.io/ and everything was ok, but when implemented Path Mapping the pain started, I’m getting this error everywhere: Cannot find module ‘@environments/environment’ or its corresponding type declarations.ts(2307) And this error applies to @environments and […]

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
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
Development

unit-tests SyntaxError: Unexpected token {

I get this error: D:\nginx\ibdrweb\webapps\ibdr-document-2\doc-app\sources\forms\dynamic-form\lus\lus.js:1 import { Tools } from “@ShareUtils/tools”; ^ SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) when i try to execute the following comand: ts-mocha -p doc-app/tests/tsconfig.json doc-app/tests/lus-tests.ts This issue was discussed here https://github.com/Microsoft/TypeScript/issues/26018 and was closed. Attempt to change “module”: “commonjs” at tsconfig.json doesn’t help. A lot of […]

Categories
Angular CSS Development

CSS rules getting omitted after transpiling in Angular 8

I upgraded my application from Angular 2 to Angular 8. I noticed few CSS rules are omitted after transpiling the code. Below is my package.json, tsconfig.json and angular.json package.json { “name”: “xxx-webapp”, “version”: “1.0.0”, “license”: “ISC”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build –base-href ./ –deploy-url /Content/Angular/Deploy/”, “test”: “ng test”, “lint”: “ng […]

Categories
Development

WebStorm breakpoints issue with TypeScript React App (using webpack)

I tried to configure the JavaScript Debugger as the WebStorm website is telling so: https://blog.jetbrains.com/webstorm/2017/01/debugging-react-apps/ However, it worked like for 2 minutes and it doesn’t work anymore, I can’t tell why.. Is it at least stable with TypeScript? Can I use the JavaScript Debugger? Edit 1 (based on @lena comment) Here you can find my […]