-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4559ed6
Types: moved all TS type descriptions to ts/ in the repo root.
jirutka 4539713
Types: added tsconfig.json and package.json for type descriptions.
jirutka 0b4ca92
Added node_modules/ and package-lock.json into .hgignore/.gitignore.
jirutka 1505741
Make: updated ts task and added ts_lint and ts_publish tasks.
jirutka 65bc79c
Make: refactored NJV_VER.
jirutka 83fdea0
Types: added tsconfig.json and package.json to test/ts.
jirutka d2a04c4
Make: reworked tasks ts_lint and ts_test to utilize npm.
jirutka fa9d234
Added COMMITHASH into njs-types package.
jirutka c5f4825
Types: fixed index types in ngx_* modules (TS2411).
jirutka 15a67d2
Types: fixed TS errors in test.ts with strict checks enabled.
jirutka c378622
Types: added missing var "console" into njs_shell.
jirutka 0206555
Types: added Readme for npmjs to njs-types.
jirutka 3f407ce
fixup: avoid using globstar bash extention in make
jirutka 4412267
fixup: fixed problem with ts_publish and NJS_TYPES_VER
jirutka 708c204
fixup: fixed compilerOptions.libs in tsconfig.json.
jirutka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| package-lock.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /node_modules/ | ||
| package-lock.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "private": true, | ||
| "name": "njs-types-test", | ||
| "version": "0.0.0", | ||
| "description": "Tests for njs TypeScript type definitions.", | ||
| "scripts": { | ||
| "test": "tsc" | ||
| }, | ||
| "author": "NGINX, Inc.", | ||
| "license": "BSD-2-Clause", | ||
| "devDependencies": { | ||
| "njs-types": "file:../../ts", | ||
| "typescript": "~4.0.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES5", | ||
| "module": "es2015", | ||
| "lib": [ | ||
| "ES2015", | ||
| "ES2016.Array.Include", | ||
| "ES2017.Object", | ||
| "ES2017.String" | ||
| ], | ||
| "noEmit": true, | ||
| "downlevelIteration": true, | ||
|
|
||
| "strict": true, | ||
| "noImplicitAny": true, | ||
| "strictNullChecks": true, | ||
| "strictFunctionTypes": true, | ||
| "strictBindCallApply": true, | ||
| "strictPropertyInitialization": true, | ||
| "noImplicitThis": true, | ||
| "alwaysStrict": true, | ||
|
|
||
| "moduleResolution": "node", | ||
| "forceConsistentCasingInFileNames": true | ||
| }, | ||
| "include": [ | ||
| "**/*.ts" | ||
| ], | ||
| "exclude": [ | ||
| "./node_modules/**" | ||
| ], | ||
| "files": [ | ||
| "./node_modules/njs-types/ngx_http_js_module.d.ts" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # TypeScript definitions for njs | ||
|
|
||
| This package contains type definitions for [njs](https://github.com/nginx/njs) – NGINX JavaScript. | ||
|
|
||
|
|
||
| ## Usage | ||
|
|
||
| Install **njs-types** from the [npm registry](https://www.npmjs.com/) into your project: | ||
|
|
||
| ```sh | ||
| # using npm: | ||
| npm install --save-dev njs-types | ||
| # or using yarn: | ||
| yarn add --dev njs-types | ||
| ``` | ||
|
|
||
| njs-types provides three entry points with global declarations for each of njs environments: | ||
|
|
||
| * `njs_shell.d.ts` – njs shell | ||
| * `ngx_http_js_module.d.ts` – NGINX JS HTTP Module | ||
| * `ngx_stream_js_module.d.ts` – NGINX JS Stream Module | ||
|
|
||
| You can either reference them using [triple-slash directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) at top of your `.ts` files (adjust `path` to point into your project’s node_modules): | ||
|
|
||
| ```ts | ||
| /// <reference path="./node_modules/njs-types/ngx_http_js_module.d.ts" /> | ||
| ``` | ||
|
|
||
| or include them using the [files](https://www.typescriptlang.org/tsconfig#files) flag in your `tsconfig.json`, for example: | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES5", | ||
| "module": "es2015", | ||
| "lib": [ | ||
| "ES2015", | ||
| "ES2016.Array.Include", | ||
| "ES2017.Object", | ||
| "ES2017.String", | ||
| ], | ||
| "outDir": "./lib", | ||
| "downlevelIteration": true, | ||
|
|
||
| "strict": true, | ||
| "noImplicitAny": true, | ||
| "strictNullChecks": true, | ||
| "strictFunctionTypes": true, | ||
| "strictBindCallApply": true, | ||
| "strictPropertyInitialization": true, | ||
| "noImplicitThis": true, | ||
| "alwaysStrict": true, | ||
|
|
||
| "moduleResolution": "node", | ||
|
|
||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| }, | ||
| "include": [ | ||
| "./src", | ||
| ], | ||
| "files": [ | ||
| "./node_modules/njs-types/ngx_http_js_module.d.ts", | ||
| ], | ||
| } | ||
| ``` | ||
|
|
||
|
|
||
| ## Versions | ||
|
|
||
| njs-types is typically being released together with njs. | ||
| Their major and minor release numbers (the first two numbers) are always aligned, but the patch version (the third number) may differ. | ||
| That's because njs-types may be updated between njs releases and in such case the patch version is incremented. | ||
|
|
||
| It's the same strategy as used in [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library). | ||
| The reason is that npmjs enforces [SemVer](https://semver.org/) which doesn't allow four-part version number nor provide post-release suffixes. | ||
|
|
||
| You can find from which commit the package was built in file `COMMITHASH` inside the published package. | ||
| It contains global revision id in the upstream repository https://hg.nginx.org/njs/ (Mercurial). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /// <reference path="njs_core.d.ts" /> | ||
| /// <reference path="njs_modules/crypto.d.ts" /> | ||
| /// <reference path="njs_modules/fs.d.ts" /> | ||
| /// <reference path="njs_modules/querystring.d.ts" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /// <reference path="njs_core.d.ts" /> | ||
| /// <reference path="../njs_core.d.ts" /> | ||
|
|
||
| declare module "crypto" { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /// <reference path="njs_core.d.ts" /> | ||
| /// <reference path="../njs_core.d.ts" /> | ||
|
|
||
| declare module "fs" { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /// <reference path="njs_core.d.ts" /> | ||
| /// <reference path="../njs_core.d.ts" /> | ||
|
|
||
| declare module "querystring" { | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.