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.

Why are interface declarations removed?

See original GitHub issue

Hi,

I’m trying to move from webpack to rollup for a library and I have trouble getting declarations to work correctly.

It seems that interfaces declarations aren’t exported, this is a problem when I have things like :

import { RenderedCell } from "../RenderedCell";

export default class MergedCell implements RenderedCell {
    // ...
}

I get the error that RenderedCell can’t be found. I worked in webpack, and I can’t understand what’s the difference in my configuration that broke this. but I seem to understand that it’s normal with Rollup.

BTW. I’m using the latest rollup, rollup-plugin-typescript2 and rollup-plugin-uglify I can post my configurations if needed

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

11reactions
yiochencommented, May 10, 2022

For what it’s worth, I just call tsc --emitDeclarationOnly after rollup, which overrides the declaration files into build folder. in my package.json

"scripts": {
    "build": "rollup -c",
    "postbuild": "tsc --emitDeclarationOnly"
}
1reaction
ezolenkocommented, Aug 15, 2017

Yep, just checked, adding import "./SomeInterface"; in the test repo fixes things.

When importing types only, typescript elides import statements from js output and rollup doesn’t see those files and thus doesn’t send them for transpiling.

I’ll try to cheat and monitor which files typescript requested from disk vs which files rollup sent for transpiling. Should be possible to force-transpile the difference with definitions only flag. This might result in too many d.ts files in some cases I though (for things rollup has legitimately shaken from the tree for example)

Read more comments on GitHub >

github_iconTop Results From Across the Web

In defense of interface: Using declaration merging to disable ...
TypeScript's interface has gotten a bit of a bad rap lately, largely because of declaration merging, a behavior of interface that's quite ...
Read more >
Why can Dart's built-in List interface be instantiated?
Notice: This question is obsolete; the interface declaration syntax has been removed from Dart: Proposal to eliminate interface declarations ...
Read more >
Defining an Interface (The Java™ Tutorials > Learning the ...
An interface declaration consists of modifiers, the keyword interface , the interface name, a comma-separated list of parent interfaces (if any), ...
Read more >
Understanding and using interfaces in TypeScript
In the above example, we can define an interface for the Tesla Model ... in the interface with the one defined in the...
Read more >
Handbook - Interfaces - TypeScript
To describe a function type with an interface, we give the interface a call signature. This is like a function declaration with only...
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