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

Mocha Test can’t find npm module

I have tests in src/test/server-new that exercise code in src/server-new the root (./) of my app which is a mono repo, I have a package.json that has these dependencies installed: "express-graphql": "^0.11.0", "graphql": "^15.3.0", these are used in src/server-new/api.js as it imports and uses those npm modules. I have a test that imports src/server-new/api.ts: src/test/server-new/my.test.spec.ts […]

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

How to enable @ experimentalDecorators in next.config.js or babelrc

Hi if someone would help me, I wanna use @Decorators on my nextjs app, but I get the following error. Hope someone knows what Im doin wrong Error message: Syntax error: Support for the experimental syntax ‘decorators-legacy’ isn’t currently enabled: I’m trying to use typeorm / type-graphql to generate my backend in an app subfolder. […]

Categories
Mastering Development

Webpack – import const from .d.ts file not working – Can’t resolve ‘@nuvolo/servicenow-types/server/GlideRecord’

I’m doing this: import { GlideRecord } from "@nuvolo/servicenow-types/server/GlideRecord"; I have a file node_modules/@nuvolo/servicenow-types/server/GlideRecord.d.ts It contains: … type GlideRecordConstructor = { new <T>(table: string): GlideRecord<T> }; type GlideRecord<T> = GlideRecordBase<T> & T; declare const GlideRecord: GlideRecordConstructor; export { GlideRecord }; If I run tsc it works, no errors Webpack says: Module not found: Error: Can’t […]

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

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

Typescript Http.Post or Fetch in Express.js app

I’m new at Typescript and I’m trying to make an OAuth2 service like I’ve done in an Express.js normal app. But I’m not able to make a simple POST request with Typescript. All the examples I’ve found say I have to use "fetch", but when I do it I get an error saying fetch is […]

Categories
Mastering Development

“Including” socket.io-client in vanilla typescript

I decided to use Typescript to create a class that will expose some methods which use socket.io-client. I have two Typescript source files and a socket.io.js (client) file: file1.ts file2.ts socket.io.js (client) file2.ts depends on file1.ts and file1.ts depends on socket.io.js. I would like to have one .js file in the end which I can […]

Categories
Mastering Development

You may need an appropriate loader to handle this file type, currently no loaders are configured to process file

I just created a project using create-react-app (in javascript). In that, I am linking one of my other repository like this { "name": "hh-frontend-example", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "hh-stylesheet": "file:../hh-stylesheet", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1" }, Here notice this line: "hh-stylesheet": "file:../hh-stylesheet", Now, When I start […]