-
Notifications
You must be signed in to change notification settings - Fork 205
Prepare TS types for publishing on npm #344
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
Conversation
3a6012f to
2862f15
Compare
5affa01 to
f63e61b
Compare
|
@jirutka |
|
This PR is not ready yet. |
d4a8571 to
611943a
Compare
|
You can try it now. However, it’s still not ready for merge. I wanted to ask, would it be acceptable to use |
yes, this is acceptable because it is for developers only, and should be called explicitly (this should not be a dependency of any common targets like njs, test etc).
from |
5dd1b34 to
3422eb1
Compare
Okay, great!
Okay, I’ve modified the Makefile in this regards. It’s almost ready. Please take a look if this approach makes sense to you. |
662fda5 to
4c38953
Compare
4c38953 to
6e8db86
Compare
37d7ff7 to
ee5de8b
Compare
|
I’ve originally suggested using the version number in format npmjs enforces SemVer which doesn’t allow four-part version number nor provide post-release suffixes. The version suffix For these reasons, I think that it will be better use a similar approach as DefinitelyTyped. I’ve described it in
When |
5b6481b to
54ed7a4
Compare
|
Here are my improvements over your work I am still working on it (planning to merge and simplify some patches further) But, I am have an issue right now with modules |
|
Well, that’s because you’ve excluded the following changes ( --- a/ts/ngx_http_js_module.d.ts
+++ b/ts/ngx_http_js_module.d.ts
@@ -1,4 +1,4 @@
-/// <reference path="index.d.ts" />
+/// <reference path="njs_core.d.ts" />
--- a/ts/ngx_stream_js_module.d.ts
+++ b/ts/ngx_stream_js_module.d.ts
@@ -1,4 +1,4 @@
-/// <reference path="index.d.ts" />
+/// <reference path="njs_core.d.ts" />
--- a/ts/njs_shell.d.ts
+++ b/ts/njs_shell.d.ts
@@ -1,4 +1,4 @@
-/// <reference path="index.d.ts" />
+/// <reference path="njs_core.d.ts" />I’ve changed references to BTW, why did you remove/didn’t include README.md? This is for npmjs.com, it automatically reads README.md from the package shows it as the package’s description. I forgot that you have to take the patch and apply it on the mercurial repository, so you cannot easily sync the changes. I should probably stop rebasing commits and just add fixups instead… I’m gonna do it for the last time now just to sync your changes back to this PR. :) Was the removal of |
With strict type checking options enabled (they are recommended to be enabled in all new TypeScript projects).
To prevent developers from accidentally committing them into the repository.
ts_test was changed to work as an integration test - it packs njs-types into a package, installs it in test/ts as a dependency, installs typescript from npm registry and then checks types in the test files using the installed tsc. The goal is to verify a typical usage scenario of the njs-types package, including the project's configuration.
Fixes the following type errors:
Property ''xxx'' of type 'NjsByteString | undefined' is not assignable to string index type 'NjsStringLike'.ts(2411)
https://www.typescriptlang.org/docs/handbook/interfaces.html#indexable-types:
> While string index signatures are a powerful way to describe the
> "dictionary" pattern, they also **enforce that all properties match
> their return type.**
54ed7a4 to
5fda5df
Compare
it is in progress, I did not get to README.md patch yet (plan to add).
yes, I plan to simply drop the test which caused the issue. The meaning of reordering is to reduce the patches size (by squashing some changes). |
5fda5df to
0206555
Compare
Okay, I’ve synced this change back to this PR. And that was the last rebase.
Yeah, I understand that. |
|
Here is my current patchset Remaining problems are:
may not work as expected, if NJS_TYPES_VER dependency can be introduced, but maybe the dump targets (no dependencies) are a better option for this very specific task. |
|
The patchset is broken because there’s missing
There should be
There are two extra spaces. Just a suggestion (I find the current indentation confusing): # auto/make:
$NJS_BUILD_DIR/test/ts/node_modules: \\
- $NJS_BUILD_DIR/njs-types-\$(NJS_TYPES_VER).tgz \\
- $NJS_BUILD_DIR/test/ts/package.json
+ $NJS_BUILD_DIR/njs-types-\$(NJS_TYPES_VER).tgz \\
+ $NJS_BUILD_DIR/test/ts/package.json
cd $NJS_BUILD_DIR/test/ts && \$(NPM) install \\
- --save-dev file:../../njs-types-\$(NJS_TYPES_VER).tgz
+ --save-dev file:../../njs-types-\$(NJS_TYPES_VER).tgz
cd $NJS_BUILD_DIR/test/ts && \$(NPM) install
I don’t have that much experience with writing (portable) Makefiles to disquish between POSIX make and GNU make.
You’re right. Here is a fix: https://github.com/nginx/njs/commit/4412267a015d5ecdf309cae004f98db4afd19742.patch |
|
You may also help us in improving the development guide for the end users (possibly for newcomers to the node.js world). I am not a JS nor node.js developer. So best practices and good examples for writing njs code using njs-types are welcome. Here is my latest patchset: https://gist.github.com/e94a527711e04011c616ccc36025e540 For example, what is the proper command to produce JS artefact using npm? (analogous to |
I’ll look into it after I actually finish the setup of my project using njs.
You just declare it as the { ...
"scripts": {
"build": "tsc test.ts"
},
...
}and then run BTW,
There is still
This commit doesn’t introduce just # /.hgignore:
+ ^build/
+ ^Makefile$# /.gitignore
+ /build/
+ /Makefile
To be perfectly correct, this commit should come after
This is incorrect, If you just wanted to avoid pipe in this subshell, you can also write it as |
|
I’ve updated |
Actually, this is not needed, because newlines are replaced with spaces in the second command substitution (for njs_test_ts_deps). |
|
@jirutka |
|
You’re welcome! Why did you release njs-types 0.5.0? The njs-types version should be aligned with the njs version and there’s no 0.5.0 yet. The latest released njs version is 0.4.4 and the types currently reflects this version, so you should release njs-types 0.4.4. |
This is my bad. I accidentally did |
Yeah, it looks like that. |
|
Merged in 07f3d66..fc08c95. |
Take a look https://gist.github.com/xeioex/95fe47ae0fce376e18de06674e6dbe50. |
This is not good, it would require providing |
Patch: https://patch-diff.githubusercontent.com/raw/nginx/njs/pull/344.patch