Questions tagged [typescript-definitions]

37 questions
40
votes
1 answer

is it possible to mark something as deprecated in typescript?

I'm writing typescript definitions for a Javascript API with a deprecated method (they say API but really it's just a single method): This API has no effect. It has been maintained for compatibility purpose. For compatibility purposes, I would…
lhk
  • 18,941
  • 21
  • 87
  • 152
10
votes
2 answers

Typescript interface, function and namespace all have the same name. Which is being exported?

In the Typescript definition file (DefinitelyTyped) I am examining, there is an interface, a function and a namespace all with the exact same name: twilio. Here is the sample, from the first few lines of the file: declare interface twilio { (sid?:…
CodyBugstein
  • 17,496
  • 50
  • 159
  • 312
9
votes
2 answers

Vue&TypeScript: how to avoid error TS2345 when import implemented in TypeScript component outside of project directory?

I got below TypeScript error when tried to use side component (outside of project directory): TS2345: Argument of type '{ template: string; components: { SimpleCheckbox: typeof SimpleCheckbox; }; }' is not assignable to parameter of type…
8
votes
1 answer

How do you import a Typescript type definition file whose top level element is a non-exported namespace?

I'm trying to use the @types/googlemaps type definition file. The code looks like declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { constructor(mapDiv: Element|null, opts?: MapOptions); …
CodyBugstein
  • 17,496
  • 50
  • 159
  • 312
6
votes
0 answers

Validate Manually Created Typescript Definition Files

Background I have created a component library using react (plain js). I am in the process of creating Typescript definitions for the components so that consumers of the component library can use the components in a type-safe manner in their…
Davie
  • 768
  • 3
  • 10
  • 24
4
votes
0 answers

How to use Phaser 3.17 GameConfig object in Typescript?

After updating Phaser to 3.17 with npm install phaser@3.17.0 I now get these Typescript errors: const config: GameConfig = { scene: [BootScene, StartScene, GameScene, GameOver], input: { keyboard: true } } Cannot find name…
Kokodoko
  • 19,176
  • 21
  • 88
  • 153
4
votes
1 answer

How to generate type definition file from TypeScript files?

I crafted some classes and modules in TypeScript. Other TypeScript apps can use the TS files directly without needing type definitions. However, to publish to npm, I guess I need to publish both JS files and the type definition files. I think it…
ZZZ
  • 2,524
  • 2
  • 20
  • 33
4
votes
1 answer

Adding properties to existing TypeScript interface via module augmentation has no effect

I have a Node application that depends on @types/hapi. I'd like to add a property to one of the classes defined in this module. I've tried defining my new property via module augmentation: // my-custom-hapi-typings.d.ts import * as hapi from…
4
votes
1 answer

dts-gen: fails to find globally installed modules

I have installed dts-gen globally npm i -g dts-gen I installed the target module globally npm i -g jhipster-core When I run dts-gen -m jhipster-core -o I get the following output: Couldn't load module "jhipster-core". Please install it globally (npm…
vivekmore
  • 332
  • 4
  • 15
3
votes
2 answers

How to import react-bootstrap component with children into kotlin-js react app

I want to use a bootstrap Card component in a react website created with kotlin-js. The app uses kotlin-react wrapper and react-bootstrap library. react-bootstrap documentation says use to put content. This is some…
2
votes
0 answers

Configure typescript to compile outside of Node or browser

I'm looking to create a sandboxed JavaScript environment, meaning standard node functions like require() or process.* shouldn't exist. And I would like TypeScript to reflect that. Instead I've got a custom .d.ts file that I would like to use as a…
2
votes
2 answers

What is the right typescript definition for a specific javascript instantiation pattern

I'm currently working on Paper.js library typescript definition and I have trouble finding the right way to document some parts of the API. The case can be reduced to the following: let's say we have an Animal class which has a static property Dog…
2
votes
1 answer

Typescript: use types for explicit import

I'm programming a webextension in Typescript. Since I would like to target both Chrome and Firefox, I need this polyfill. Importing it looks like this: import browser from "webextension-polyfill" Typescript complains could not find a declaration…
lhk
  • 18,941
  • 21
  • 87
  • 152
2
votes
0 answers

JavaScript project with global typescript definitions in VS Code?

I have been trying to figure this out for the longest time. Let's say I have a Node.js project that uses .js files. Let's also say that I have a custom definition.d.ts file I want to use to provide Intellisense auto-completes when using proper a…
2
votes
0 answers

Referencing library types in Typescript declaration files (without importing globals)

Background I've been trying to contribute some additions to the Typescript definitions for Mocha. Mocha's Runner inherits from NodeJS EventEmitter. In my .d.ts file, I expressed this by adding: /// and declaring the…
1
2 3