You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ I am a little afraid that I am not going to do TypeScript justice.
10
10
The reason for that is that we are going to use it heavily - but in a rather indirect way.
11
11
12
12
See - we are a big fan of a [buildless]() development setup. We have [a post]() or [two]() about it :grimmacing:
13
-
It is [our believe](https://open-wc.org/about/rationales.html) that it is the best way to bring developers (you) and the platform (browser) back on the same table.
13
+
It is [our belief](https://open-wc.org/about/rationales.html) that it is the best way to bring developers (you) and the platform (browser) back on the same table.
14
14
15
-
Knowing this makes it hard to root for TypeScript as it is a [Transpiler Language]() - in other words it requires a build step.
15
+
Knowing this makes it hard to root for TypeScript as it is a [Transpiler Language]() - in other words, it requires a build step.
16
16
17
17
So how come we are still fans?
18
18
Let's dive into and see what Types can give you.
@@ -40,11 +40,11 @@ export function square(number: number) {
40
40
41
41
So yeah I know what you have been thinking - a string as an argument?
42
42
While implementing we found out that it was a bad idea.
43
-
And thanks to the power of types we can just go back to our code/tests and tada we immeditelly see in vscode that `square('two')` is not working.
43
+
And thanks to the power of types we can just go back to our code/tests and tada we immediately see in vscode that `square('two')` is not working.
test/helpers.tests.js:13:22 - error TS2345: Argument of type'"ten"' is not assignable to parameter of type'number'.
@@ -177,7 +177,7 @@ test/helpers.tests.js:13:22 - error TS2345: Argument of type '"ten"' is not assi
177
177
~~~~~
178
178
```
179
179
180
-
Also in both cases the only thing we needed to add was `offset = 0` as it contains the type information already.
180
+
Also in both cases, the only thing we needed to add was `offset = 0` as it contains the type information already.
181
181
182
182
If you wanna know more about how to use JSDoc for types I can recommend you these blog posts.
183
183
@@ -186,7 +186,7 @@ If you wanna know more about how to use JSDoc for types I can recommend you thes
186
186
187
187
### Publishing a library
188
188
189
-
If someone is to use your code you will need to publish it. Usually that happens on npm.
189
+
If someone is to use your code you will need to publish it. Usually, that happens on npm.
190
190
You will also want to provide those types to your users.
191
191
That means you will need to have `*.d.ts` files in the package you are publishing.
192
192
As those are the only files that `TypeScript` respects by default in the `node_modules` folder.
@@ -220,13 +220,13 @@ e.g. the output of the js file is exactly the same we wrote in our js version.
220
220
#### What does it means for JavaScript?
221
221
222
222
Sadly as of now `tsc` does not support generating `*.d.ts` files from JSDoc annotated files.
223
-
But it probably will be in the future. The original [issue](https://github.com/microsoft/TypeScript/issues/7546) is from 2016 but recently it has been said was planned for `3.6` (but it didn't make it into beta) so it seems it on the board for for `3.7`. However don't take my word for it as here is a working [Pull Request](https://github.com/microsoft/TypeScript/pull/32372).
223
+
But it probably will be in the future. The original [issue](https://github.com/microsoft/TypeScript/issues/7546) is from 2016 but recently it has been said was planned for `3.6` (but it didn't make it into beta) so it seems it on the board for `3.7`. However, don't take my word for it as here is a working [Pull Request](https://github.com/microsoft/TypeScript/pull/32372).
224
224
225
225
And it is working so great that we are using it even in production for [open-wc](https://github.com/open-wc/open-wc/blob/master/package.json#L7).
226
226
227
227
> WARNING
228
228
> This is an unsupported version => if something does not work no one is going to fix it.
229
-
> Therefore if your usecase is not supported you will need to wait for the offical release of TypeScript to support it.
229
+
> Therefore if your use-case is not supported you will need to wait for the official release of TypeScript to support it.
230
230
231
231
So you have been warned if you still think it's a good idea to test it you feel free to do so.
232
232
We published a forked version [typescript-temporary-fork-for-jsdoc](https://www.npmjs.com/package/typescript-temporary-fork-for-jsdoc) which is just a copy of what the above Pull Request is providing. (again to be clear - we did not change anything it is a temporary fork which is good enough for our use case).
@@ -266,7 +266,7 @@ Congratulations you now have a type safety without a build step :tada:
266
266
267
267
It comes down two 2 things
268
268
269
-
- Typings can be immensely useful (type safety, autocomplete, documentation, ...) for you and/or your users
269
+
- Typings can be immensely useful (type safety, auto-complete, documentation, ...) for you and/or your users
270
270
- TypeScript is very flexible and supports types for "just" JavaScript as well
271
271
272
272
Follow us on [Twitter](https://twitter.com/openwc), or follow me on my personal [Twitter](https://twitter.com/dakmor).
0 commit comments