Categories
Mastering Development

Webpack 5 + Angular 11 Error: ./node_modules/msnodesqlv8/build/Release/sqlserverv8.node 1:2

I’m using Webpack 5 and Angular 11 when I execute the command ng build –prod && ng run test-app:server:production In the console it gives me an error message: Error: ./node_modules/msnodesqlv8/build/Release/sqlserverv8.node 1:2 Module parse failed: Unexpected character ‘�’ (1:2) You may need an appropriate loader to handle this file type, currently no loaders are configured to […]

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

How to propperly build react modular library

I’m trying to create a react components library which is based on Typescript and SASS. The components library will be used in multiple other typescript projects, so type exports are needed as well. Ideally I want to mimic something like "Material-UI"/"React-Bootrap" libraries dist output solutions. Example project structure: |Tabs +–Tabs.tsx +–Tabs.scss +–index.tsx index.tsx index.tsx export […]

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