How to correctly build NestJS app for production with node_modules dependencies in bundle?

Out of the box, nest cli does not support including the node_modules dependencies into the dist bundle. However, there are some community examples of custom webpack configs that include the dependencies in the bundle, e.g. bundled-nest. As described in this issue, it is necessary to include the webpack.IgnorePlugin to whitelist unused dynamic libraries.

How to use yup’s object.shape with typescript?

following the yup guide here you should change your code as follows: import { object, SchemaOf, string } from ‘yup’; interface BaseBootstrapSchema { APPLICATION_NAME: string; LOG_PATH: string; } const bootstrapValidationSchema: SchemaOf<BaseBootstrapSchema> = object({ LOG_PATH: string().required(“The ‘LOG_PATH’ ENV variable is required”), APPLICATION_NAME: string().required(“The ‘APPLICATION_NAME’ ENV variable is required”), }); module.exports = (schema: SchemaOf<BaseBootstrapSchema>) => new Promise((resolve, … Read more

How to use Puppeteer in an Angular application

How to use Angular e2e testing with Puppeteer 1) Install Puppeteer npm install –save-dev puppeteer @types/puppeteer 2) Configure Protractor to use Puppeteer Edit your protractor.conf.js and add the following inside capabilities: // … const puppeteer = require(‘puppeteer’); exports.config = { // … capabilities: { browserName: ‘chrome’, chromeOptions: { args: [‘–headless’], binary: puppeteer.executablePath(), }, }, // … Read more

How to dynamically mutate “args” in Storybook v6 from the component’s action?

I had the same exact issue, and kept looking for days, till I stumbled upon this github post: https://github.com/storybookjs/storybook/issues/12006 Currently in my React (am sure vue approach will be similar), I do following: import React from ‘react’; import CheckboxGroupElement from ‘../CheckboxGroup’; import { STORYBOOK_CATEGORIES } from ‘elements/storybook.categories’; import { useArgs } from ‘@storybook/preview-api’; export default … Read more

How to ‘map’ a Tuple to another Tuple type in Typescript 3.0

You’ll need to use a mapped tuple type, which is supported in TypeScript 3.1. You can make a mapped type that has properties 0, 1, 2 and length of the correct types, like this: class Maybe<T> {} type MaybeTuple = [Maybe<string>, Maybe<number>, Maybe<boolean>]; type MaybeType<T> = T extends Maybe<infer MaybeType> ? MaybeType : never; type … Read more

How is the correct way to work with Vuex and typescript?

Vuex is perfectly compatible with typescript using these vuex imports: import {GetterTree, MutationTree, ActionTree} from “vuex” The example below shows the easiest and most complete way to use vuex in typescript. Principal store file: import Vue from ‘vue’ import Vuex from ‘vuex’ import { GetterTree, MutationTree, ActionTree } from “vuex” import MySubModule from ‘@/store/submodule’ Vue.use(Vuex) … Read more

Why duck typing is allowed for classes in TypeScript

This is the way structural typing works. Typescript has a structural type system to best emulate how Javscript works. Since Javascript uses duck typing, any object that defines the contract can be used in any function. Typescript just tries to validate duck typing at compile time instead of at runtime. Your problem will however only … Read more