Skip to content

Commit

Permalink
Version 5.1.0 (#34)
Browse files Browse the repository at this point in the history
## Main changes

* Support [Tail-Recursion Elimination on Conditional Types](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#tailrec-conditional), that comes with TypeScript 4.5 and allows users to use more variables (infinity?), than before. Fixes #27.

## Chore

* Update dependencies
* Update "Known issues" section and links to types in `README.md`
* Add a test for a big amount of variables
* Change spaces to tabs
  • Loading branch information
vasilii-kovalev committed Nov 21, 2021
1 parent 62e4e70 commit 24694f9
Show file tree
Hide file tree
Showing 16 changed files with 4,380 additions and 4,207 deletions.
8 changes: 6 additions & 2 deletions .editorconfig
Expand Up @@ -2,8 +2,12 @@ root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
indent_style = tab
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

# For a pretty visual representation.
[*.md]
indent_size = 2
indent_style = space
438 changes: 219 additions & 219 deletions .eslintrc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Lint
uses: borales/actions-yarn@v2.3.0
with:
cmd: lint
cmd: lint:check
- name: Test
uses: borales/actions-yarn@v2.3.0
with:
Expand Down
32 changes: 20 additions & 12 deletions .prettierrc
@@ -1,14 +1,22 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "auto",
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
"arrowParens": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "auto",
"jsxSingleQuote": false,
"printWidth": 80,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"useTabs": true,
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
@@ -1,3 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
"typescript.tsdk": "node_modules\\typescript\\lib"
}
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -23,7 +23,7 @@ A small, dependency-free and strongly typed template engine.
[minzip-size-badge]: https://flat.badgen.net/bundlephobia/minzip/hydrate-text
[size-link]: https://bundlephobia.com/package/hydrate-text
[types-badge]: https://flat.badgen.net/npm/types/hydrate-text
[types-link]: https://github.com/vasilii-kovalev/hydrate-text/blob/main/src/index.ts#L1-L75
[types-link]: https://github.com/vasilii-kovalev/hydrate-text/blob/main/src/index.ts#L1-L90
[coverage-badge]: https://flat.badgen.net/coveralls/c/github/vasilii-kovalev/hydrate-text
[coverage-link]: https://coveralls.io/github/vasilii-kovalev/hydrate-text
[vulnerabilities-badge]: https://flat.badgen.net/snyk/vasilii-kovalev/hydrate-text
Expand Down Expand Up @@ -145,13 +145,14 @@ function configureHydrateText(
) => typeof hydrateText;
```

Check out [types.ts](./src/types.ts) file for more information.
Check out the "Types" section in the [source file](./src/index.ts) for more information.

## Known issues

- If a string has more than 8 variables, an error "Type instantiation is excessively deep and possibly infinite" can occur. In this case, it is better to break the string down into several pieces.
- SyntaxError: Unexpected token 'export'.

Check out the [original TypeScript issue](https://github.com/microsoft/TypeScript/issues/37613) for more information.
The problem appears when running tests using Jest. That's because of lack of CommonJS support. A solution can be found [here](https://github.com/vasilii-kovalev/hydrate-text/issues/32).
Not supporting CommonJS is intended, since all the industry is moving towards ES modules, and CommonJS will be retired at some point.

## Background

Expand Down
10 changes: 5 additions & 5 deletions jest.config.json
@@ -1,7 +1,7 @@
{
"collectCoverageFrom": ["src/index.ts"],
"testEnvironment": "node",
"transform": {
"^.+\\.ts$": "@swc-node/jest"
}
"collectCoverageFrom": ["src/index.ts"],
"testEnvironment": "node",
"transform": {
"^.+\\.ts$": "@swc-node/jest"
}
}
124 changes: 63 additions & 61 deletions package.json
@@ -1,63 +1,65 @@
{
"name": "hydrate-text",
"version": "5.0.2",
"description": "A small, dependency-free and strongly typed template engine.",
"sideEffects": false,
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"keywords": [
"javascript",
"string",
"template engine",
"template",
"tree-shakable",
"typescript",
"zero-dependency"
],
"author": "Vasilii Kovalev <vasilii.kovalev95@yandex.ru>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/vasilii-kovalev/hydrate-text.git"
},
"homepage": "https://github.com/vasilii-kovalev/hydrate-text#readme",
"bugs": {
"url": "https://github.com/vasilii-kovalev/hydrate-text/issues"
},
"scripts": {
"tslint": "tsc --project tsconfig.tslint.json",
"types": "check-dts **/*.ts",
"eslint:check": "eslint src",
"eslint:fix": "eslint src --fix",
"prettier:check": "prettier . --check",
"prettier:fix": "prettier . --write",
"lint": "npm-run-all tslint types eslint:check prettier:check",
"test": "jest --coverage",
"build": "tsc --project tsconfig.build.json",
"postbuild": "prettier dist --write",
"prepare": "npm-run-all build",
"prepublishOnly": "npm-run-all lint test",
"postversion": "git push && git push --tags"
},
"devDependencies": {
"@swc-node/jest": "^1.3.1",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.5",
"@typescript-eslint/eslint-plugin": "4.28.5",
"@typescript-eslint/parser": "4.28.5",
"check-dts": "^0.5.4",
"eslint": "7.31.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jest": "24.4.0",
"eslint-plugin-prettier": "3.4.0",
"jest": "^27.0.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"typescript": "^4.3.5"
}
"name": "hydrate-text",
"version": "5.1.0",
"description": "A small, dependency-free and strongly typed template engine.",
"sideEffects": false,
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"keywords": [
"javascript",
"string",
"template engine",
"template",
"tree-shakable",
"typescript",
"zero-dependency"
],
"author": "Vasilii Kovalev <vasilii.kovalev95@yandex.ru>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/vasilii-kovalev/hydrate-text.git"
},
"homepage": "https://github.com/vasilii-kovalev/hydrate-text#readme",
"bugs": {
"url": "https://github.com/vasilii-kovalev/hydrate-text/issues"
},
"scripts": {
"tslint": "tsc --project tsconfig.tslint.json",
"types": "check-dts",
"eslint:check": "eslint src",
"eslint:fix": "eslint src --fix",
"prettier:check": "prettier . --check",
"prettier:fix": "prettier . --write",
"lint:check": "npm-run-all tslint types eslint:check prettier:check",
"lint:fix": "npm-run-all tslint types eslint:fix prettier:fix",
"test": "jest --coverage",
"check": "npm-run-all lint:check test",
"build": "tsc --project tsconfig.build.json",
"postbuild": "prettier dist --write",
"prepare": "npm-run-all build",
"prepublishOnly": "npm-run-all check",
"postversion": "git push && git push --tags"
},
"devDependencies": {
"@swc-node/jest": "^1.4.1",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.9",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"check-dts": "^0.6.4",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jest": "25.2.4",
"eslint-plugin-prettier": "4.0.0",
"jest": "^27.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.4.1",
"typescript": "^4.5.2"
}
}

0 comments on commit 24694f9

Please sign in to comment.