Skip to content

Exported type not found #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tarnadas opened this issue Jun 21, 2018 · 5 comments
Closed

Exported type not found #144

Tarnadas opened this issue Jun 21, 2018 · 5 comments
Labels

Comments

@Tarnadas
Copy link

Tarnadas commented Jun 21, 2018

When exporting a type and importing it in another file, it cannot be found.

// A.ts
export type A = int16;

let a: A = 0; // works

// B.ts
import { A } from 'A' // throws error: ERROR TS2305: Module './A' has no exported member 'A'.
@LiaoPeng
Copy link
Contributor

It's alias type.
You can try this in B.ts
import 'A'
And 'A' represent file A.ts.

@Tarnadas
Copy link
Author

This indeed works, but it isn't intended behavior I guess?

What if I have other exported things inside A.ts? I wouldn't want to write import { ... } from 'A'; import 'A';. If I now use type A, the TypeScript compiler also shows me an error, which is suboptimal.

@MaxGraey
Copy link
Member

Actually best practice store all type definitions in "*.d.ts" file which allow include all this types in top level and via tsconfig

@dcodeIO
Copy link
Member

dcodeIO commented Jun 21, 2018

Types are currently somewhat special in that these become program globals and do not follow import/export semantics as one might expect. Needs improvement.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 7, 2019

Closing in favor of #473, which is our tracking issue for similar related issues now.

@dcodeIO dcodeIO closed this as completed Feb 7, 2019
@dcodeIO dcodeIO mentioned this issue Feb 19, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants