-
Notifications
You must be signed in to change notification settings - Fork 11
Standardize Terminologies #12
Comments
It is a bit easier to discuss here. 🌹 |
Translating Typings terms to TypeScript termsAmbientIs probably just External module declarationBased in TypeScript terms, what we described as Ambient module declaration
|
Interesting on the translating. I thought I was pretty accurate to the TypeScript terms. Global is a new feature for augmentation. When you say all typings are ambient, are you talking about from the consumption perspective or the publishing perspective? When we publish, they definitely aren't ambient - the basic distinction from TypeScript is that ambient declarations have no top level |
They seems to define it neutrally:
|
The |
I'll continue to update the two above comments as we discuss. So that when we are done, they will be close to a complete doc. Feel free to edit them. 🌹 |
On this note:
Seems like they do not have a clean distinction between the two. That's why they have that paragraph there and it prohibits mapping. However they have the the phrase top-level declaration, that's why I guess it could be ambient top-level module declaration or ambient top-level namespace declaration for |
Sounds good, I think you've got this covered better than me at this point. |
🍺
|
Terms to clarify:
|
source vs distribution channel vs package manager vs delivery mechanism |
lib vs env vs global in registry |
Script vs global in |
Conversation transferrred from Gitter: https://github.com/typings/registry#structure
Hmm. Without examples those 3 definitions don't hold a great deal of meaning. Having read the above I couldn't tell you on what basis you'd choose where to put mocha / Angular / jquery etc. They all seem to be different shades of the same thing. And without a clear distinction, a satisfactory way to draw the line, I think the difference is unhelpful to users. As it stands I think this just provides confusion which could well be avoided. Happy to be put right if there is a clear rule that can be applied 💐 To summarise: we need clear definitions for the following:
Without clear definitions I feel we should think about whether these terms are helpful and worth keeping. |
Related to the registry structure, I'm having difficulty in asking the right question in the generator: |
@unional I'm guessing you've refactoring since then. What are you asking? I thought
|
Wrap vs unwrap version terminology: |
To me at least
Totally.
That would seem to be a clear ish rule (and worth recording if so).
Not trying to be difficult by the way. I'm just thinking that if it's not clear in our own minds (well, my own mind!) then that confusion is likely to result in things getting badly categorised in the Registry and users also rather puzzling over where they're supposed to find things. |
I've been bugging Blake to death on many things. I think he handles it well. 😜 |
He does! 🌷 |
They are similar, I just wanted to separate the odd-balls that were external modules from the odd-balls that were ambient declarations. That's pretty much it. Check out what's in |
With |
Will check our
I'm not too sure what this means? Do you mean
I don't quite follow this. When I'm using jasmine I include the jasmine.d.ts which brings |
Yes, that's the |
Just for clarity - this is true in the case where you share context between your Sorry to bang on, just want to be sure I understand you correctly. |
Yes, correct.
It is possible with the current format (DefinitelyTyped) since it would mix the module and the environment definitions together in one file. That would cause usage where you're just using the module import syntax to also include the globals like |
I don't quite follow that? As I understand it, contexts are built based on Perhaps an example. Here's a repo of mine. It has this test In the test code here we do not use So in this case jasmine is already part of
I don't think it is possible to use But it is possible? 😕 |
BTW, whilst jasmine becomes part of the environment, react-addons-testutils does not (imported). Sorry for confusion. |
I don't think we're discussing the same thing. Let's try to reset. You've got the Simple example: https://github.com/blakeembrey/co-mocha. That's a plugin manipulating the programmatic API of Mocha, not the environment |
You may be right about the 🚬☁ (closest emoji gets to "pipedream). I think I follow you. Unfortunately I can't see any examples in the Registry that nicely demonstrate the delineation. I kind of feel that if we want this to happen we need something to point at and say "do it like this! Behold the wonderful good practice!" Any candidates? Mocha looks like it only appears in |
Sure, I can go in and do one as an example. Mocha is what I'm most familiar with - it would be putting one version in |
Thanks - that'd be v helpful! Btw is there a scenario when a Typing could appear in env as well as lib as well as global? Or is it one only? |
Yes, Edit: Not to say that |
Ta. So if something is in lib it isn't anywhere else? |
Nope, definitely not. |
Cool. Rules as understood so far:
|
👍 The only thing I'd change is phrasing on |
Yeah - you're right. Need careful description. 👍 |
How to write typings
When you write typed definitions for DefinitelyTyped, you create a pull request on DefinitelyTyped with the corresponding
.d.ts
file and you are done. In the.d.ts
file you write either anambient internal module
orambient external module
as in the handbook.Things are a little bit different when you write a definition with Typings.
While it is definitely not harder than writing typed definitions for DefinitelyTyped, there isn't a clear term of reference on how to write a definition with Typings.
First things first...terminology
Going through the handbook and spec to understand everything you need to write typings is a great thing to do, but it isn't fun. Also, since TypeScript is rapidly improving, some information in the handbook is out of date.Here are a list of terms that are relevant in writing typings so you can cut the chase.
If you like to learn by example, you can skim through this section and read the next one. Things will become more clear as you move along.
Typescript terminologies
ambient (declaration)
http://www.typescriptlang.org/Handbook#modules-working-with-other-javascript-libraries
.d.ts
filesambient modules
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#ambient-modules
declare module "name" {
.ambient namespaces
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Namespaces.md#introduction
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Namespaces.md#ambient-namespaces
declare namespace D3
+declare var d3: D3.Base
to declare global object.declare var d3
is needed because in the exampleD3
is a non-instantiated namespace.external module
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md
export =
andimport = require()
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#export--and-import--require
export =
, TypeScript-specificimport X = require("module")
must be used to import the module.https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#support-for-default-import-interop-with-systemjs
import X from 'module';
orimport * as X from 'module';
. The exact behavior depends onmodule: system|commonjs
andallowSyntheticDefaultImports: true|false
.internal module
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Namespaces.md#introduction
module
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#111-modules
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#16-classes
module keyword
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Namespaces%20and%20Modules.md
module X {
is equivalent to the now-preferrednamespace X {
declare module X {
, you are actually writingdeclare namespace X {
.microsoft/TypeScript#6808
module
keyword will be gradually deprecated.module pattern
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#110-namespaces
namespace
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Namespaces.md#namespacing
top-level declaration
, see below)https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#10-namespaces
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#110-namespaces
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#101-namespace-declarations
top-level declaration
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#23-declarations (need to scroll down a bit)
declare namespace X {
creates a global namespaceX
.declare namespace X {
in such file does not create global namespaceX
.References
module
keyword in new code wherenamespace
could be used? microsoft/TypeScript#6808The text was updated successfully, but these errors were encountered: