closure-compiler
closure-compiler copied to clipboard
A JavaScript checker and optimizer.
`Array.pop` and `Array.shift` methods do not get type-checked correctly, at least not by Typescript standards. Example: ```js /** * @param {Array} names */ function hello(names) { /** @type {string} */...
`Array.reduce` method does not get type-checked correctly. Eample: ```js /** * @type {Array} */ const arr = [1,2,3] const sum = arr.reduce((a, b) => a + b, 0); ``` Raises...
```js /** * @type {{ x: number, y: number, w: number, h: number }} */ const rect = { x: 0, y: 0, w: 100, h: 100 }; /** *...
Interfaces do not check return type of methods when `return` is not called. ```js /** @interface */ function ISerializable() {}; /** @type {function(): string} */ ISerializable.prototype.serialize; /** * @implements {ISerializable}...
The type checking of promises has several issues with it. 1. `Promise.resolve` is not type checked correctly when called without argument ```js /** * @type {Promise} */ const p =...
It is not clear how to generate source maps that can be used to debug code on localhost, which is arguably a very common use case. What is certain, is...
As described [here](https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System), the `typeof` operator is probably not intended to be used on inferred types. However, in Typescript it is possible to do it, and it is in fact...
Looking at the [documentation of compiler flags](https://github.com/google/closure-compiler/wiki/Warnings), specifically those, that are OFF by default, there are many problems. Let's break it down: ### Some flags have a wrong default value...
Empty record type is not supported. ```js /** * @type {{}} // WARNING - [JSC_TYPE_PARSE_ERROR] Bad type annotation. type not recognized due to syntax error. */ const x = {}...
Arguments of `typeof` are not type-checked. ```js /** * @type {{ id: string }} */ const data = { id: "123" } const x = data.somethingMadeUp // type-checked // WARNING...