Skip to content

Commit 61eeab2

Browse files
committed
changes to README and tests
1 parent ecc5814 commit 61eeab2

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `typed-string-interpolation`
22

3-
[String interpolation](https://en.wikipedia.org/wiki/String_interpolation) utility that returns the correct `TypeScript` type based on passed in variables.
3+
[String interpolation](https://en.wikipedia.org/wiki/String_interpolation) for `TypeScript` with correct return types based on passed in variables.
44

55
![Library in use with React](docs/cover.png)
66

src/__tests__/stringInterpolation.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { stringInterpolation } from "../index"
22

33
describe("stringInterpolation()", () => {
4-
// Throws
54
test("Empty", () => {
65
expect(() => {
76
stringInterpolation("", {
@@ -24,7 +23,6 @@ describe("stringInterpolation()", () => {
2423
})
2524
).toThrow("Variable 'world' not found")
2625
})
27-
// Succesful outputs
2826
test("Interpolate single variable", () => {
2927
expect(
3028
stringInterpolation("Hello {{world}}", {
@@ -43,7 +41,7 @@ describe("stringInterpolation()", () => {
4341
)
4442
).toStrictEqual(["Hello ", "world with variable"])
4543
})
46-
test.only("Interpolate two variables", () => {
44+
test("Interpolate two variables", () => {
4745
expect(
4846
stringInterpolation("Hello {{world}} and {{anotherVariable}}", {
4947
world: "world with variable",

src/__typetests__/stringInterpolation.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@ expectType<
6363
},
6464
})
6565
)
66+
67+
expectType<(string | number | Date)[]>(
68+
stringInterpolation("hello {{one}} {{two}} {{three}}", {
69+
one: "one",
70+
two: 2,
71+
three: new Date(),
72+
})
73+
)

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"noEmit": true /* Disable emitting files from a compilation. */,
66
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
77
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
8-
"strict": true /* Enable all strict type-checking options. */
8+
"strict": true /* Enable all strict type-checking options. */,
9+
"jsx": "react"
910
},
1011
"exclude": ["dist", "node_modules"]
1112
}

0 commit comments

Comments
 (0)