Questions tagged [typescript-typings]

DO NOT USE IT AS A SYNONYM OF TYPES. Use for questions on typings, a package for managing TypeScript definitions. It uses typings.json, which can resolve to the Typings Registry, GitHub, NPM, Bower, HTTP, and local files. The package is now deprecated.

Usage guidance

Use for questions about the now deprecated typings package.

Do not use as a synonym of "types", use or instead. If your question is about type definitions, use instead. Also consider using more specific tags like depending on the topic of the question.

If your question concerns the project that replaced typings, use instead.

About

Typings is an older way of managing TypeScript definition files.

Typescript typings is deprecated in favor of NPM @types packages.

References

  1. Typings on NPM
  2. GitHub repository
3302 questions
298
votes
3 answers

How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

I use TypeScript 2 in my project. I'd like to use some js library, but also typings for that library. I can install types with simple npm install @types/some-library. I'm not sure if I should --save or --save-dev them. It seems to me that even…
kamyl
  • 4,048
  • 2
  • 19
  • 27
223
votes
12 answers

Typescript input onchange event.target.value

In my react and typescript app, I use: onChange={(e) => data.motto = (e.target as any).value}. How do I correctly define the typings for the class, so I wouldn't have to hack my way around the type system with any? export interface InputProps…
wildeyes
  • 3,859
  • 5
  • 16
  • 33
178
votes
12 answers

Overriding interface property type defined in Typescript d.ts file

Is there a way to change the type of interface property defined in a *.d.ts in typescript? for example: An interface in x.d.ts is defined as interface A { property: number; } I want to change it in the typescript files that I write to…
Abdul23
  • 2,236
  • 2
  • 13
  • 21
144
votes
3 answers

TypeScript typings in npm @types org packages

I've noticed there's an npm organization @types, which contains typing packages, but can't find any documentation on it. How are these meant to be used? Is it meant to be used with typings tool? If so, how to install them? For instance, there's a…
Ronald Zarīts
  • 9,173
  • 8
  • 35
  • 39
124
votes
5 answers

Import class in definition file (*d.ts)

I want to extend Express Session typings to allow use my custom data in session storage. I have an object req.session.user which is an instance of my class User: export class User { public login: string; public hashedPassword: string; …
Michał Lytek
  • 5,693
  • 3
  • 13
  • 22
110
votes
7 answers

Property 'X' is private and only accessible within class 'xyzComponent'

I'm trying to build angular2 application for production for that I'm following this blog. After my ngc successful compilation when the tsc compilation takes place it generates below error shown in the image: After searching for a while I found…
Sumit Khanduri
  • 3,009
  • 7
  • 23
  • 38
97
votes
4 answers

Having error "Module 'name' resolves to an untyped module at..." when writing custom TypeScript definition file

I can't find TypeScript definition @type/{name} for one of my installed NodeJS packages, so I attempt to write a d.ts file for it, and put the file in {project root}\typings folder. This is how I do: // My source code: index.ts import Helper from…
hirikarate
  • 2,346
  • 2
  • 16
  • 27
97
votes
1 answer

How to configure custom global interfaces (.d.ts files) for TypeScript?

I'm currently working on a ReactJS project which uses Webpack2 and TypeScript. Everything works perfectly apart from one thing - I can't a find a way to move interfaces that I've written myself into separate files so that they are visible to the…
Andris
  • 4,543
  • 2
  • 24
  • 34
94
votes
4 answers

TypeScript 2: custom typings for untyped npm module

After trying suggestions posted in other places, I find myself unable to get a typescript project running that uses an untyped NPM module. Below is a minimal example and the steps that I tried. For this minimal example, we will pretend that lodash…
Jodiug
  • 3,233
  • 4
  • 22
  • 38
85
votes
8 answers

Typescript: Type X is missing the following properties from type Y length, pop, push, concat, and 26 more. [2740]

I have this Product interface: export interface Product{ code: string; description: string; type: string; } Service with method calling product endpoint: public getProducts(): Observable { return…
mpro
  • 10,634
  • 4
  • 20
  • 35
67
votes
10 answers

Angular 4+ using Google Analytics

I'm trying to use the Google Analytics with angular 4, but i can't find any @type to ga.js in ts. For a quick solution I used this in every component: declare let ga: any; Following how I resolved it: Create a function to load the GA dynamically…
64
votes
4 answers

ts-node ignores d.ts files while tsc successfully compiles the project

Having compiled my TypeScript project successfully, I intended to run it in VS Code's debug mode using ts-node. Problem is, ts-node can't find d.ts files I created (while tsc has no problem with it). Project structure is: / conf/ dist/ …
Forseti
  • 1,536
  • 1
  • 15
  • 27
64
votes
3 answers

Typescript: How to add type check for history object in React?

I have the following piece of code, which receives a history object as prop: const ChildComponent = ({ history }) => (
Ivin Jose
  • 3,405
  • 7
  • 38
  • 60
62
votes
7 answers

TypeScript typings give me "index.d.ts is not a module"

I am getting File node_modules/@types/webrtc/index.d.ts is not a module with this code: import * as webrtc from "webrtc"; const peerConnection1 = new RTCPeerConnection(); I have installed the typings using npm i @types/webrtc --save-dev. Hovering…
Tomáš Hübelbauer
  • 5,273
  • 8
  • 46
  • 86
61
votes
3 answers

Typescript 2.0. "types" field in tsconfig.json

I do not understand the meaning of types field in tsconfig.json. In documentation I have read such text: "types": { "description": "Type declaration files to be included in compilation. Requires TypeScript version 2.0 or later.", "type":…
Stalso
  • 1,230
  • 2
  • 11
  • 19
1
2 3
99 100