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
35
votes
0 answers

What's the difference between Map and Record

I don't quite get what the difference between Map and Record in Typescript is. The only comparison I found was A very useful built-in type introduced by Typescript 2.1 is Record: it allows you to create a typed map and is great for creating…
Alexander Berndt
  • 351
  • 1
  • 3
  • 6
33
votes
3 answers

Global types in typescript

Is there a way to make a file in your typescript file that defines globally accessible types? I like typescript but find that when i want to be truly type safe I have to explicitly import types from all over the system. It's rather annoying.
Tal
  • 920
  • 2
  • 7
  • 19
32
votes
4 answers

Define a list of optional keys for Typescript Record

I want to type an object which can only have keys 'a', 'b' or 'c'. So I can do it as follows: Interface IList { a?: string; b?: string; c?: string; } They are all optional! Now I was wondering if this can be written with Record in just…
Jeanluca Scaljeri
  • 19,619
  • 37
  • 147
  • 259
31
votes
1 answer

Saving npm @types typings with --save or --save-dev

TypeScript 2 recommends using npm for types. In The Future of Declaration Files. the example is: npm install --save @types/lodash My question is whether --save-dev should be used in an application, because TypeScript is transpiled and not deployed?…
30
votes
2 answers

How does one add a typing to typings.json for Typescript in Visual Studio 2015?

I have to ask because this is driving me crazy. I see the npm way of installing typings on Google, but Angular2's tutorial has one add a typings.json file then it added the typings folder and downloaded d.ts files from DefinitelyTyped…
29
votes
3 answers

TypeScript in Visual Studio 2017: Automatic definition inclusion causes Duplicate Identifier errors

UPDATE: I've got a workaround that makes things work acceptably with no hacks. I leave my prior attempts described below for posterity. See the answer for the working solution. I've just upgraded an project to Visual Studio 2017 and I'm getting all…
Brian Rak
  • 4,220
  • 5
  • 27
  • 40
29
votes
2 answers

Exclude/overwrite npm-provided typings

I've got an npm package with badly written, out of date typings. I've written my own typings and now I'm wondering if I can somehow exclude the original typings from the npm package. It's not a simple extension of interfaces, the originals are…
Simon Meskens
  • 824
  • 6
  • 12
29
votes
5 answers

Typescript and JQuery compile error: Cannot find name '$'

I'm testing typescript with jquery, but when I compile the test.ts file, it always gives me an error indicating: Cannot find name '$'. I've already imported jquery & added its definition reference. If I use import $ = require("jquery") in my test.ts…
Mark Yuan
  • 760
  • 1
  • 6
  • 16
28
votes
4 answers

parameter implicitly has an 'any' type

I'm using visual studio code for a typescript project, where I use some 3rd party npm js libraries. Some of them don't provide any ts types (types.d.ts file), so whenever I use parameters or variables without specifying their type, vs code's linting…
Ronin
  • 5,059
  • 3
  • 29
  • 52
27
votes
3 answers

Add custom typings file in a JavaScript VSCode project

Problem I am working on JavaScript project using VSCode. I am using the UMD design pattern and vscode intellisense cannot recognize the exports of a module from another file. I added all the declarations in a file called globals.d.ts. Unfortunately…
nick zoum
  • 6,639
  • 5
  • 26
  • 63
26
votes
7 answers

How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found"

My React app is not failing to compile due to the error: Definition for rule '@typescript-eslint/consistent-type-assertions' was not found I'm kind of at a loss. I'm unable to find any current rule definitions in the project. The project was…
ezagala
  • 261
  • 1
  • 3
  • 5
26
votes
1 answer

How to manually update a deprecated typings package

I have a NodeJS application that I'm writing in TypeScript. It uses many Node packages. Not all of these packages have Typescript definitions, so I use Typings to get the separate definition files. When I deploy my application to the production…
Travesty3
  • 14,336
  • 6
  • 52
  • 95
26
votes
5 answers

error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist

Even though I've installed & referenced the Typings library 'react' like this /// I'm still getting the error below: Is there another Typings library I should be installing as well?
Richard
  • 9,237
  • 13
  • 60
  • 88
25
votes
1 answer

Typescript does not copy d.ts files to build

So maybe I'm confused, but I thought that if I added declaration:true to my tsconfig.json I could have it tsc copy my *.d.ts files, along side the transpiled code & it's d.ts files? EG: - src - lib - types.d.ts - foo.ts I would expect the…
NSjonas
  • 7,200
  • 5
  • 42
  • 78
25
votes
1 answer

How to use React useRef hook with typescript?

Ia m creating a reference using the new useRef hook const anchorEl = React.useRef(null) And using like
CESCO
  • 5,396
  • 4
  • 41
  • 73