Namespace as module name
See original GitHub issueIs there any way to have modules named after namespaces? To have something like:
export module $Namespace
{
$Classes(*VM)[
export class $Name {
$Properties[
// $LoudName
public $name: $Type = $Type[$Default];]
}]
}
I need it to be able to import multiple typings to my Angular2 component. Unless there is a better way to do it?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Documentation - Namespaces and Modules
Namespaces are simply named JavaScript objects in the global namespace. This makes namespaces a very simple construct to use. Unlike modules, they can...
Read more >Module vs Namespace - Import vs Require Typescript
Namespaces are used to organize/encapsulate your code. External modules are used to organize/encapsulate your code AND to locate your code at ...
Read more >Namespaces vs Modules
A namespace can include interfaces, classes, functions, and variables to support a group of related functionalities. Unlike JavaScript, namespaces are inbuilt ...
Read more >TypeScript Namespace VS Module: Understanding The ...
Namespaces provide a way to group related code together under a single namespace, while modules provide a way to organize code into separate ......
Read more >Module Files Are Namespaces - Learning Python [Book]
In Python-speak, modules are a namespace—a place where names are created. And names that live in a module are called its attributes. Technically,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gregveres Sorry for the delay. Honestly my feelings about my setup have taken a downturn. Also, they may not be sufficient for your use cases. My use cases are rather simple, I am primarily generating types, not values. Here is how I generate interfaces from server side model classes:
Sorry for the poor readability, whitespace generation is a major pain. Anyway, on build of the containing .csproj, I have a powershell script that enumerates the director to generate an index and re-exports everything, but this is just a convenience because in the same script I copy the directory to the client side project.
Ok. Do you really need that? Do interfaces need to go into separate namespaces? They don’t generate any real code, just a definition that is referenced.
I put all of my interfaces into a single namespace called SkyCourtAPI (my thought there was that it was all part of the definition of the API to interact with the server.). Also, since these are just interfaces, there is no import that is needed. I just reference them with their namespace qualified name. So even if you do want to separate your interfaces into separate namespaces, you don’t need the complications of imports. Imports are a pain in the butt to infer. I ended up creating an attribute that indicates where the class should be imported from.
I am using Knockout so I do generate Knockout versions of my interfaces. These are real classes, not just interfaces because they create the code that creates a set of knockout observable variables from the C# member fields. In this case, I do have some C# inheritance going on that translates into typescript inheritance of my knockout classes. This is where the import attribute comes in.
I am also using attributes to control which C# structures are being exported. I have [ExportToTypescript] to generate an interface and [ExportToTypescriptWithKnockout] to generate the knockout class.
if you email me greg . veres at rogers dot com, I will send you my tst files. and we can have a conversation about how to use them.