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.

How to export Class and Type

See original GitHub issue
src/
  - foo.ts
  - index.ts

foo.ts

type Bar = {

}
export class Foo {
  bar: Bar
}

index.ts

import { Foo } from './foo'

export class Index {
  person: Foo
}

output

export declare type Bar = {};
declare class Foo {
	bar: Bar;
}
export declare class Index {
	person: Foo;
}

export {};

There are two issues:

  1. Foo is not exported.
  2. Bar is exported.

why? I am very confused.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
musicodecommented, Jul 17, 2019

I find exporting .d.ts files is the hardest part of typescript.

I really don’t know how to export the type I want.

0reactions
musicodecommented, Jul 18, 2019

@timocov Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In typescript, how to export the type of a private class without ...
My goal is to export just the "type" of the private class without letting an module consuming code be able instantiate it directly....
Read more >
Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword.
Read more >
Example of TypeScript Export Function - eduCBA
By the use of an export keyword, we can export class, function, file, interface, type, etc. in TypeScript. By default it comes up...
Read more >
How to use a decorated, exported class as type #41231 - GitHub
You do this by declaring and exporting a type named Bar ...
Read more >
export - JavaScript - MDN Web Docs
Every module can have two different types of export, named export and default export. You can have multiple named exports per module but ......
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