-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
need export relative external module from ambient module decl. #2516
Comments
silly question, what is the problem with calling the module "metadata/index" instead of "./metadata/index"? The problem is given this definition: declare module "aurelia-metadata" {
export * from "./metadata/index"
} that it is not clear were the "./" is relative too. is it relative to the current file (.d.ts) the referencing .ts file? or something else? |
will that work if the contents of (and it has a corresponding i was hoping it would be relative to the current file (.d.ts) |
i could surrender and manually copy the info from the compiler-generated origin.d.ts, resource-type.d.ts, and metadata.d.ts into the ambient module declaration, but have been trying to find a way to just expose what is exported in index.d.ts, as that is the public api for the module in the repo. the issue with the manual approach is that there are already 20+ libraries, they will continue to grow, and if updating the api can't be done using the compiler, i will be forever tracking the changes in the repos and updating the api manually. i believe that the public api for each repo must be an ambient module because the actual path to the corresponding import ( |
Assuming you have declare module 'aurelia/origin' {
export class Origin {
}
} You can import / reexport it as /// <reference path="./origin/origin.d.ts"/>
declare module 'aurelia' {
export * from 'aurelia/origin';
} Verified from usage: /// <reference path="./aurelia"/>
import {Origin as Origin1} from "aurelia/origin";
import {Origin as Origin2} from "aurelia"; In shortTell me exactly the TS you want to write i.e. the Usage and then we can come up with a definition for it. ❤️ |
@cmichaelgraham note that my files exist online for your testing https://github.com/TypeStrong/atom-typescript-examples/tree/master/externalModulesDefinition |
i will perform additional validation today, but your guidance made it possible to build the .d.ts files using gulp-typescript and then incorporate the results into ambient module declarations shown here i am VERY grateful for your help !!! 😄 |
For any interested parties, here is a public github repo that illustrates the working compiler results. Thanks to @basarat & @mhegazy for the guidance !! aurelia-ts-port
The process is to take the ES6 Aurelia source code, maintain a local copy here for comparison when porting across new code changes: Using the source from above, the next step in the process is to create equivalent, matching typescript source code by copying The (gulp-based) build process then compiles the typescript aurelia source code, creating the clone and build
you should now see folders in the process steps - to add aurelia repos (or add new files):
|
thanks @cmichaelgraham for sharing. I would be interested to know how did the conversion process go? what are the issues you ran into? |
I struggled a bit figuring out the right combination of files and configuration settings. The TypeScript 1.5 compiler is beautiful, in my opinion. The ES6 code syntax ports over very well. It would also probably be helpful to have some guidance on what Overall, this is right on target. I do think some tooling would be useful - if I could say: "generate an ambient |
thanks @cmichaelgraham for the feedback. i have created issue #2568 to track the single declaration file generation. |
@cmichaelgraham FWIW atom-typescript now has integrated Both exporting and importing should just work ™️ . |
I am trying to facilitate use of TypeScript with ES6-based modular set of github repos. I am struggling with this pattern:
typescript compiler wont allow
export declaration in an ambient external module declaration that references an external module through relative external module name
the repos use
systemjs
andjspm
to resolveaurelia-metadata
. i want to use ambient module declarations to expose the types fromaurelia-metadata
what i'm trying to achieve is effectively the same as copying the contents of
origin.d.ts
,resource-type.d.ts
, andmetadata.d.ts
into the ambient module declaration inaurelia.d.ts
.note that
./metadata/index.js
basically publishes the public interface through its exports, and that is precisely what i want to expose in the ambient module declarationThe text was updated successfully, but these errors were encountered: