Skip to content

Commit c3ebad5

Browse files
committed
chore: some typos, rename image
1 parent b991582 commit c3ebad5

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: -
55
tags: javascript, typescript, jsdoc, buildless
66
---
77

8-
At [open-wc](https://open-wc.org), we are big fans of [buildless](https://dev.to/open-wc/on-the-bleeding-edge-3cb8) development setups. We have [a post](https://dev.to/open-wc/developing-without-a-build-1-introduction-26ao) or [two](https://dev.to/open-wc/developing-without-a-build-2-es-dev-server-1cf5) about it 😄. [We believe](https://open-wc.org/about/rationales.html) that the future is all about coming back to the web platform. That means relying on native browser features in preference to userland or JavaScript solutions or development tools. That's why we have made it our mission to provide you the developer with the tools and techniques to use the platform *today*, even before legacy browsers are finally dropped.
8+
At [open-wc](https://open-wc.org), we are big fans of [buildless](https://dev.to/open-wc/on-the-bleeding-edge-3cb8) development setups. We have [a post](https://dev.to/open-wc/developing-without-a-build-1-introduction-26ao) or [two](https://dev.to/open-wc/developing-without-a-build-2-es-dev-server-1cf5) about it 😄. [We believe](https://open-wc.org/about/rationales.html) that the future is all about coming back to the web platform. That means relying on native browser features in preference to userland or JavaScript solutions or development tools. That's why we have made it our mission to provide you the developer with the tools and techniques to use the platform _today_, even before legacy browsers are finally dropped.
99

10-
This approach grants us tremendous advantages in <abbr title="developer experience">DX</abbr>, performance, and accessibility, but there are drawbacks. JavaScript, famously, is dynamically typed. Developers who want to enjoy type checking at development time will typically reach for Microsoft's TypeScript, Facebook's Flow, or Google's Clojure compiler. All of these require a build step.
10+
This approach grants us tremendous advantages in <abbr title="developer experience">DX</abbr>, performance, and accessibility, but there are drawbacks. JavaScript, famously, is dynamically typed. Developers who want to enjoy type checking at development time will typically reach for Microsoft's TypeScript, Facebook's Flow, or Google's Clojure compiler. All of these require a build step.
1111

1212
Can we enjoy a safely typed developer experience while "staying true" to the web platform? Let's first dive in and see what Types can give us.
1313

@@ -78,11 +78,11 @@ Now, if we go back to our test file, we no longer see the error at `square('two'
7878

7979
![In the JavaScript version of the test file, Visual Studio Code no longer shows the error on line 3 when string is called with a string](https://raw.githubusercontent.com/daKmoR/generate-typescript-definition-files-from-javascript/master/images/02-js-square-two.png)
8080

81-
If you're thinking "Oh well, JavaScript is dynamically typed, there's nothing to be done about it", then check this out: we actually can acheive type safety in vanilla JavaScript, using JSDoc comments.
81+
If you're thinking "Oh well, JavaScript is dynamically typed, there's nothing to be done about it", then check this out: we actually can achieve type safety in vanilla JavaScript, using JSDoc comments.
8282

8383
## Adding Types to JavaScript Using JSDoc
8484

85-
[JSDoc](https://jsdoc.app/) is a long-standing inline documentation format for JavaScript. Typically, you might use it to automatically generate documentation for your server's API or your [web component's attributes](https://github.com/runem/web-component-analyzer). Today, we're going to use it to acheive type safety in our editor.
85+
[JSDoc](https://jsdoc.app/) is a long-standing inline documentation format for JavaScript. Typically, you might use it to automatically generate documentation for your server's API or your [web component's attributes](https://github.com/runem/web-component-analyzer). Today, we're going to use it to achieve type safety in our editor.
8686

8787
First, add a JSDoc comment to your function. The docblockr plugin for [VSCode](https://marketplace.visualstudio.com/items?itemName=jeremyljackson.vs-docblock) and [atom](https://atom.io/packages/docblockr) can help you do this quickly.
8888

@@ -121,10 +121,10 @@ Next, we'll configure the TypeScript compiler to check JavaScript files as well
121121

122122
> Hey! I thought you said we weren't going to be using TypeScript here?!
123123
124-
You're right, although we will be authoring and publishing browser-standard JavaScript, our edidor tools will be using the [TypeScript Language Server](https://github.com/theia-ide/typescript-language-server) under the hood to provide us with type-checking.
124+
You're right, although we will be authoring and publishing browser-standard JavaScript, our editor tools will be using the [TypeScript Language Server](https://github.com/theia-ide/typescript-language-server) under the hood to provide us with type-checking.
125125
Doing this allows us to get exactly the same behaviour in VSCode and Atom as with TypeScript.
126126

127-
![Screenshot of VSCode showing the same typechecking as in the first figure, but using the annotated JavaScript files](https://raw.githubusercontent.com/daKmoR/generate-typescript-definition-files-from-javascript/master/images/03-js-square-two-typed.png)
127+
![Screenshot of VSCode showing the same type-checking as in the first figure, but using the annotated JavaScript files](https://raw.githubusercontent.com/daKmoR/generate-typescript-definition-files-from-javascript/master/images/03-js-square-two-typed-error.png)
128128

129129
We even get the same behaviour when running `tsc`.
130130

@@ -147,7 +147,7 @@ expect(square(2, 10)).to.equal(14);
147147
expect(square(2, 'ten')).to.equal(14);
148148
```
149149

150-
However it appears that they probably should have spent those hours sleeping, as our original typecasting bug is still there.
150+
However, it appears that they probably should have spent those hours sleeping, as our original typecasting bug is still there.
151151

152152
How can we deliver this critical (😉) feature to our customers quickly while still maintaining type safety?
153153

@@ -159,7 +159,7 @@ export function square(number: number, offset = 0) {
159159
}
160160
```
161161

162-
The provided default value let's TypeScript statically analyse the code the *infer* the value.
162+
The provided default value let's TypeScript statically analyse the code to _infer_ values type.
163163

164164
We can get the same effect using our vanilla-js-and-jsdoc production implementation:
165165

@@ -215,15 +215,15 @@ export function square(number, offset = 0) {
215215
### Publishing JavaScript Libraries
216216

217217
Sadly, as of now `tsc` does not support generating `*.d.ts` files from JSDoc annotated files.
218-
We hope it will in the future, an in fact, the original [issue](https://github.com/microsoft/TypeScript/issues/7546) for the feature is still active, and it seems to be on the board for `3.7`. Don't take our word for it, the [Pull Request](https://github.com/microsoft/TypeScript/pull/32372) is in flight.
218+
We hope it will in the future, and in fact, the original [issue](https://github.com/microsoft/TypeScript/issues/7546) for the feature is still active, and it seems to be on board for `3.7`. Don't take our word for it, the [Pull Request](https://github.com/microsoft/TypeScript/pull/32372) is in flight.
219219

220220
In fact, this works so well that we are using it in production for [open-wc](https://github.com/open-wc/open-wc/blob/master/package.json#L7).
221221

222222
> !WARNING!
223223
> This is an unsupported version => if something does not work no one is going to fix it.
224224
> Therefore if your use-case is not supported you will need to wait for the official release of TypeScript to support it.
225225
226-
We took the liberty of publishing a forked version [typescript-temporary-fork-for-jsdoc](https://www.npmjs.com/package/typescript-temporary-fork-for-jsdoc) which is just a copy of the above pull request.
226+
We took the liberty of publishing a forked version [typescript-temporary-fork-for-jsdoc](https://www.npmjs.com/package/typescript-temporary-fork-for-jsdoc) which is just a copy of the above pull request.
227227

228228
## Generate TypeScript Definition Files for JSDoc Annotated JavaScript
229229

@@ -252,6 +252,7 @@ We have exactly this setup at [open-wc](https://github.com/open-wc/open-wc) and
252252
Congratulations you now have a type safety without a build step :tada:
253253

254254
## Conclusions
255+
255256
To sum it all up - why are we fans of TypeScript even though it requires a build step?
256257

257258
It comes down to 2 things:
@@ -272,4 +273,3 @@ Follow us on [Twitter](https://twitter.com/openwc), or follow me on my personal
272273
Make sure to check out our other tools and recommendations at [open-wc.org](https://open-wc.org).
273274
274275
Thanks to [Benny](https://dev.to/bennypowers), [Lars](https://github.com/LarsDenBakker) and [Pascal](https://twitter.com/passle_) for feedback and helping turn my scribbles to a followable story.
275-
File renamed without changes.

0 commit comments

Comments
 (0)