-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Suggestion : Documentation about a proper/clean way to reuse types/interfaces in Babel 7 #22326
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
Comments
You can export an interface or type alias directly from a module. You don't need to use a namespace. export interface I { x: number; } b.ts import { I } from "./a";
const i: I = { x: 0 }; |
Thanks for the support. The thing I suggest in OP was to use the .d.ts file for the // import custom interfaces/types
import { I } from "./src/b";
declare class X implements I {
// ...
} /src/b.ts export interface I { x: number; } Edit : I heard that could be some name conflict when using modules that uses same name for interface/types. Didn't know if the module class template prevent this case when stripped of the namespace for Babel ... |
The compiler can automatically generate |
The suggested config used here set noEmit : tsc --init --noEmit --allowJs --allowSyntheticDefaultImports --target esnext And as the docs said :
I think a --declarationOnly flag can be useful to handle case like that .. Edit: My main file has this d.ts after tsc export {}; |
For that you can use the |
Thanks. No wonder I didn't know that stuff : that is something new not yet in the docs online. Another stuff that could be added inside the TypeScript-Babel-Starter repo ^^ |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Hello,
I think there should be a complex example to use Babel 7 with TypeScript.
The documentation I used before this suggestion : module-class.d.ts
and babel-plugin-transform-typescript
For example, I have a library that exports a class but have inner modules to do that stuff (and I don't like Triple-Slash Directives)
For that, In the package.json, the 'types' entry refers to index.d.ts
The problem is I want to use TypeScript with Babel and import types/interfaces in files I need :
The text was updated successfully, but these errors were encountered: