alexjoverm / typescript-library-starter

Starter kit with zero-config for building a library in TypeScript, featuring RollupJS, Jest, Prettier, TSLint, Semantic Release, and more!
MIT License
4.37k stars 493 forks source link

How to define types for local JS file #260

Closed sonovice closed 5 years ago

sonovice commented 5 years ago

I am having troubles using a simple one-file JS library with this template. This is my folder structure:

src/app.ts
src/verovio.js <-- the library
src/types/verovio.d.ts

The app.ts consists of the following:

/// <reference path="./types/verovio.d.ts" />
import * as verovio from './verovio'

And verovio.d.ts:

declare module 'verovio' // Todo: Dirty, do it properly!

I've also put src/types into the typeRoots property of my tsconfig.json (which shouldn't be necessary anymore). But I still get the same error over and over again:

error TS7016: Could not find a declaration file for module './verovio'. '/foo/bar/project/src/verovio.js' implicitly has an 'any' type.

Any ideas what I'm doing wrong? This is at least how I got it to work in another project.