Questions tagged [module-augmentation]
28 questions
0
votes
0 answers
How to augment Koa DefaultState?
I tried to augment DefaultState in Application.Koa to contain userId?: number, but to no avail, the said state remains typed as any, and IntelliSense doesn't offer suggestions.
In the @types/koa it is stated:
declare namespace Application {
type…

Bratelion
- 11
- 3
0
votes
0 answers
Material UI - Module Augmentation from NPM Package
I'm working on setting up a package to use for my @mui/material theme. I want to have a package @my/theme that will have all my MUI related style overrides and my theme so that I can install that and use my theme everywhere. The package itself…

Frenchy
- 90
- 1
- 10
0
votes
1 answer
Can't use module augmentation to collocate a type safe API
I'm trying to create a strictly typed API that only allows valid inputs.
The API uses firestore internally, which admits any JSON document as a valid input, and I want to strictly limit what are valid inputs, both in the document path and the…

Danielo515
- 5,996
- 4
- 32
- 66
0
votes
1 answer
How to augment the mocha module?
Given Cypress 10.3.1 which has Mocha 3.5.3 in devDependencies.
I want to add new functions to mocha Context.
In cypress/support/e2e.ts I do import './context';. And in cypress/support/context.ts I have:
import { Context } from 'mocha';
declare…

Marcus
- 1,857
- 4
- 22
- 44
0
votes
0 answers
Typescript: can't augment namespace
I'm using "amazon-connect-streams" npm package. The package has a few mismatches between the type definition and the javascript runtime.
I'm trying to override the bad typing in my project, using namespace augmentation, but can't figure out how to…

gamliela
- 3,447
- 1
- 35
- 41
0
votes
1 answer
Extend material ui theme options using module augmentation not working with TypeText
Here is a codesandbox to reproduce the issue.
https://codesandbox.io/s/thirsty-sun-0zyb3?file=/src/newTheme.ts:0-401
The TypeText is not being accepted, but the SimplePaletteColorOptions is working. It's the same thing, I don't understand where I…

Gaurav
- 98
- 3
- 13
0
votes
1 answer
TypeScript: Typing the result of an external module's non-mutating extension function
Let's say I'm using external package "foo". Its main export is an object which has an .extend() method that can be used to add functionality by creating a derived object (the original is left unchanged). It looks something like this:
import foo from…

Inkling
- 3,544
- 4
- 30
- 44
0
votes
1 answer
How to convert custom type definition file to npm type definition file
I have a custom module definition file for a dependency written in CoffeeScript in my typescript project.
It looks like the following and works great:
src/@types/dependency-name.d.ts
declare module 'dependency-name' {
import EventEmitter from…

glinda93
- 7,659
- 5
- 40
- 78
0
votes
1 answer
Monkey patching a javascript class property without `configurable=true`
it seems that I'm in a bad situation here.
I'm using a javascript library and I need to augment a property inside a class but it seems that it can't be done because the property definition does not set configurabe: to true.
Here is the library…

Kleber
- 942
- 1
- 15
- 25
0
votes
2 answers
Unable to compile when augmenting OktaAuthService typescript module
Scenario:
My project is using the latest version of @okta/okta-angular. It exports the class 'OktaAuthService'. I would like to use module augmentation to add a method to it
What I've tried
import { OktaAuthService } from…
0
votes
1 answer
Typescript module augmentation with a third party module and namespace
So, I wanted to extend the AWS SDK DynamoDB class to have a new scan implementation that overcomes the 1 MB limitations (see AWS documentation and SO post). Found documentation on typescript module augmentation (looked at the example in the official…

Rudolfs Bundulis
- 11,636
- 6
- 33
- 71
0
votes
1 answer
How to batch process with multiple Bounding Boxes in imgaug
I'm trying to set up a data augmentation pipline with imgaug. The transformation of the images works and does not throw any errors. In the second attempt I tried to transform the N Bounding Boxes for each image and I get a persistent error.
def…

john-mueller
- 107
- 2
- 9
0
votes
1 answer
How to augment @types/mocha?
I tried to apply Aluan's answer in countless different ways, but none worked, that is, none gave me the sweet auto-complete for the types that I augmented:
augmentations.d.ts
import { Foo } from './foo';
declare module "mocha" {
namespace Mocha…

Paul Razvan Berg
- 16,949
- 9
- 76
- 114