question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add "Typings" file to NPM package for Typescript consumers

See original GitHub issue

I’ve been working on a Cesium-based project for a few months now, and picked Visual Studio Code as my primary editor. I was a little irritated that other libraries I rely on (like Moment and jQuery) have good feedback from Intellisense, while Cesium doesn’t give me anything (out of the box, at least). I learned that this is because the more popular libraries have a “Typings” file (.d.ts) either available from an external source, or bundled into the Node module directly.

I found this repo and placed the index.d.ts in my node_modules/cesium/ and like magic, VSCode knew the types of all the Cesium classes and functions – except that listing was last updated 4 months ago with version 1.26, so it was missing stuff that’s changed in the last half-dozen or so releases. I’ve added some things to it myself, though I wouldn’t say it’s definitely complete. I can post my modified version if anybody would like that.

I recognize that this would be an ongoing requirement, either to maintain manually or to generate as part of your build workflow, but I think it would really help out both those that try to use Cesium from actual Typescript, and those that work with vanilla-JS Cesium from VSCode.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:39 (36 by maintainers)

github_iconTop GitHub Comments

3reactions
beginorcommented, Oct 13, 2017

@thw0rted I have move your gist to a public repo https://github.com/beginor/cesium-typings , this make it easy for others to contribute.

Any star or fork is welcome.

2reactions
thw0rtedcommented, Sep 23, 2017

If anybody is tracking, I went ahead and hand-jammed some 1.37.0 updates to the Typings file I found earlier: https://gist.github.com/thw0rted/c0c73335c9968d5e7b6dd18a43ef6c42

I’m sure it’s still missing some information or wrong in places, and I don’t have automated tooling in place to generate this, which is what’s really needed. Still no workaround as far as I know for the issue I raised back in August – Typescript still really doesn’t want you to use getter/setter pairs the way Cesium does, so you might have to do use type guards or casts in your consuming code that wouldn’t otherwise be necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a typescript definition file to a npm package?
Try to load a file named index.d.ts located in the package folder (node_modules/foo/) - this file should contain typings for the package. The ......
Read more >
Documentation - Publishing - TypeScript
There are two main ways you can publish your declaration files to npm: bundling with your npm package; publishing to the @types organization...
Read more >
How to create strongly-typed npm packages - Medium
npm install pets --save ..in the petstore package folder and then consume the package directly from its TypeScript sources: · import {Cat} from...
Read more >
The 30-second guide to publishing a TypeScript package to ...
The 30-second guide to publishing a TypeScript package to NPM · 1. Add "declaration": true to the compilerOptions of your tsconfig.json · 2....
Read more >
Step by step: Building and publishing an NPM Typescript ...
The package can be used both for Typescript and Javascript users! If your library becomes popular there will sooner or later be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found