Categories
Mastering Development

Typescript ignores decorated mobx properties on class type definition

This is a simplified example. I have a class definition using decorators like: export default class AnimationController { @observable animationTime: number = 0; @computed({keepAlive: true}) get interpolatedJoints(){} @computed({keepAlive: true}) get currentAnimation(){} } elsewhere I am importing this class to use as a type definition and getting an error when accessing these expected properties. import AnimationController […]

Categories
Mastering Development

NestJS Testing: decorator is not a function

My dependencies: "@nestjs/common": "7.4.4", "@nestjs/core": "7.4.4", "typescript": "4.0.2", "jest": "26.4.2", "jest-junit": "11.1.0", "ts-jest": "26.3.0", I have a custom decorator: import { Inject } from "@nestjs/common"; import { DATABASE_SERVICE } from "./database.constants"; export const InjectDatabase = () => Inject(DATABASE_SERVICE); I use it in constructor for a service I’m willing to cover with tests: import { DatabaseService, […]

Categories
Mastering Development

typescript .d.ts file not recognized by typescript but vsc

Update: it isnt a typescript, but ts-node "issue" i answered to myself so if ure still interested in the "issue" – read further 🙂 sorry for the confusion maybe I have a TOTALLY wrong idea of the index.d.ts file.. but my idea was, that i can declare types within it and they are then "globally […]

Categories
Mastering Development

Typescript error — Error: Cannot find module ‘typescript/tsc.js’

I cannot figure out how to make my ‘tsc’ command working: tsc –version module.js:472 throw err; ^ Error: Cannot find module ‘typescript/tsc.js’ at Function.Module._resolveFilename (module.js:470:15) My ‘package.json’ has: "devDependencies": { "@types/node": "^14.11.2", "tslib": "^2.0.1", "typedoc": "^0.19.2", "typescript": "^4.0.3" } And my ‘tsconfig.json’: { "compilerOptions": { "target": "es6", "sourceMap": true, "declaration": true, "declarationDir": "dist/types", "strict": true, […]

Categories
Mastering Development

Type declaration error despite adding .d.ts file

I am using a npm package called update-immutable which happens to not have a typescript definition available built in or by @types. So I created a type definition file in my project and now VS Code detects the proper types for this package. However with noImplicitAny option set to true, Angular’s compiler doesn’t seem to […]

Categories
Mastering Development

Usage of recoil in custom NPM component

I’m trying to use recoil in a custom npm component so that i can publish and use it in an application but upon usage getting error as below: Invalid hook call. Hooks can only be called inside of the body of a function component… > const useStoreRef = () => useContext(AppContext); I’m using following rollupjs […]

Categories
Mastering Development

A type error in WorkBox routing when defining HeadersInit value

I’m currently trying to create a Service Worker with TypeScript and WorkBox. The following is my current WorkBox definition (just to get something going). How could I solve the type error that I explain the following? In the registerRoute piece TypeScript compiler tells that matchPrecache expect two parameters, the other being of type HeadersInit. If […]

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

System limit for number of file watchers reached

I try to run my project on the ubuntu server. command: npm run production it calls webpack-dev-server –config webpack.prod.js –mode production –inline –progress After it builds I get a lot of issues: Error from chokidar (/root/galyan/client/node_modules/@material-ui/icons): Error: ENOSPC: System limit for number of file watchers reached, watch ‘/root/galyan/client/node_modules/@material-ui/icons/index.d.ts’ Error from chokidar (/root/galyan/client/node_modules/@material-ui/icons): Error: ENOSPC: System […]

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