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.

Typings definitons for Typscript

See original GitHub issue

I’m trying to use lunr in a fresh Angular 2 app installed with the cli.

In the app.module.ts I’m trying to import lunr with

import { lunr } from 'lunr';

But I keep getting errors about that not being a module, or it not finding it. (yes lunr is in the node_modules folder)

I think/guess that it needs a Typings definition? I found this one. But it seems to be considerably out of date, and doesn’t solve the problem https://www.npmjs.com/package/@types/lunr

Or is that not what I need?

TIA

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
jbouzekricommented, Sep 1, 2017

@kchiragowni : As @gnomeontherun said, there is really nothing special to do.

If you are using angular cli :

npm install --save lunr
npm install --save-dev @types/lunr

In tsconfig.json, add :

{
  "compilerOptions": {
    "types":[
      "lunr"
    ]
  }
}

And in your component ts file, you can do the same thing as in the lunr guide :

import * as lunr from 'lunr';

const idx = lunr(function () {
  this.ref('name')
  this.field('text')

  documents.forEach(function (doc) {
    this.add(doc)
  }, this)
});
1reaction
olivernncommented, Apr 10, 2017

I’m happy to re-open the issue as I think having TypeScript definitions would be awesome.

That said, I really don’t think they should live in this repository.

I’m not familiar with the process of creating a typings file, can this not be something that is automated for each new release? Or some kind of test that can highlight missing or incorrect typings?

Do you have some examples of other JavaScript libraries and where they keep their type definitions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Type Declarations - TypeScript
Built-in Type Definitions. TypeScript includes declaration files for all of the standardized built-in APIs available in JavaScript runtimes.
Read more >
Typescript Typings: The Complete Guide: @types Compiler ...
The @types scope package contains type definitions for a lot of libraries, like Express, Sequelize, JQuery, and many others. So definitively ...
Read more >
typings/typings: *DEPRECATED* The TypeScript Definition ...
Typings is the simple way to manage and install TypeScript definitions. It uses typings.json , which can resolve to the Typings Registry, GitHub,...
Read more >
Surviving the TypeScript Ecosystem — Part 4 - Medium
The solution is to make a type definition file. A type definition file is a file that ends in “.d.ts”. It is a...
Read more >
TypeScript: Adding Custom Type Definitions for Existing ...
In this case, we're going to make a new folder inside our src folder called customTypings to hold all our definition files, and...
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