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
57
votes
9 answers

Typescript, how to pass "Object is possibly null" error?

I've got the "Object is possibly null" error many times and usually I use a safety "if statement" in case it returns null. I've got the following function: const ModalOverlay = (props: any[]) => { const overlayEl = useRef(null); useEffect(()…
SixtyEight
  • 976
  • 2
  • 6
  • 18
57
votes
1 answer

Usage of the TypeScript compiler argument 'skipLibCheck'

I've been researching around for a further explanation into the skipLibCheck TypeScript compiler argument to determine the safety of having this set to true. The most in-depth explanation I found is the following: New --skipLibCheck TypeScript…
Daniel Lowman
  • 582
  • 1
  • 4
  • 11
54
votes
4 answers

How should I use @types with TypeScript 2

So far we are used to tsd or (The better version of it) typings But now that TypeScript 2 offers the new @types feature, how should I convert my current project to work with @types? I have tsd.json (typings.json is some cases) with all the…
gilamran
  • 5,914
  • 4
  • 27
  • 48
52
votes
3 answers

Keyof inferring string | number when key is only a string

I define an AbstractModel like so: export interface AbstractModel { [key: string]: any } Then I declare the type Keys: export type Keys = keyof AbstractModel; I would expect that anything with the Keys type would be interpreted univocally as a…
don
  • 2,942
  • 11
  • 36
  • 59
52
votes
5 answers

TypeScript character type?

My question is very brief. I am new to TypeScript, been searching around here and there but didn't find yet an answer. Does any experienced TypeScripter know if there is a character Type or an easy way to achieve one?
charliebrownie
  • 4,591
  • 8
  • 28
  • 49
50
votes
1 answer

A namespace-style import cannot be called or constructed, and will cause a failure at runtime

Strange stuff happening here, with TypeScript 2.7.2, in VSCode version 1.21 with @types/express and the code that follows, in some cases VSCode throws errors stating that "A namespace-style import cannot be called or constructed, and will cause a…
John Gorter
  • 1,328
  • 2
  • 11
  • 19
48
votes
3 answers

Types from both keys and values of object in Typescript

I have two sets of string values that I want to map from one to the other as a constant object. I want to generate two types from that mapping: one for keys and one for values. const KeyToVal = { MyKey1: 'myValue1', MyKey2:…
dx_over_dt
  • 8,418
  • 13
  • 39
  • 65
47
votes
4 answers

What are Typings in Typescript

I am new to Angular2 and I'm enjoying it so far but there is one problem: Typings. I can't figure out how to use them and what exactly they are. Some places say to use typings, others say to use npm to install definitions. I'm confused!!
Ikiugu
  • 576
  • 1
  • 5
  • 14
46
votes
2 answers

What is "DefinitelyTyped"?

I see "DefinitelyTyped" is something related to TypeScript/JavaScript development, but I couldn't understand its use or some code sample to understand about it. I looked at http://definitelytyped.org/ and http://bartvds.github.io/projects/dt.html…
Venkatesh
  • 463
  • 4
  • 6
43
votes
7 answers

How to import CSS modules with Typescript, React and Webpack

How to import CSS modules in Typescript with Webpack? Generate (or auto-generate) .d.ts files for CSS? And use classic Typescript import statement? With ./styles.css.d.ts: import * as styles from './styles.css' Import using require Webpack…
Diego Laciar
  • 1,496
  • 1
  • 12
  • 7
42
votes
3 answers

Write a declaration file for a default export module

I have a npm module called RiveScript that usually (in Javascript) gets instantiated that way: var RiveScript = require('rivescript'); var rivescript = new RiveScript(); I'm trying to write a declaration file for the module, but am stuck at the…
julien_c
  • 4,351
  • 5
  • 37
  • 52
40
votes
3 answers

What is the TypeScript 2.0 / ES2015 way to import assert from Node.js?

I'm running TypeScript 2.0.3, configured to with "target": "es2015",. I started with /// import assert = require('assert'); But in Visual Studio, that gets flagged with a tooltip…
Burt_Harris
  • 5,336
  • 1
  • 24
  • 55
39
votes
1 answer

typings vs @types NPM scope

In some cases typings is used for handling TypeScript definitions (e.g. angular/angular2-seed). In other cases scoped NPM @types packages are used with no typings involved (e.g. AngularClass/angular2-webpack-starter). What are the practical…
Estus Flask
  • 150,909
  • 47
  • 291
  • 441
36
votes
3 answers

Where should I place custom .d.ts files?

I'm trying to provide typings for the package that does not have them: error TS7016: Could not find a declaration file for module 'inputmask-core'. './node_modules/inputmask-core/lib/index.js' implicitly has an 'any' type. Try `npm install…
Rogach
  • 22,915
  • 19
  • 81
  • 160
35
votes
2 answers

required url param on React router v5 with typescript, can be undefined

I am using react-router v5.1 with TypeScript and have this route configurations: and I…
Or Bachar
  • 1,183
  • 2
  • 13
  • 19