Skip to content

The typeof x === "number" guard has stopped working #9923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
d180cf opened this issue Jul 24, 2016 · 1 comment
Closed

The typeof x === "number" guard has stopped working #9923

d180cf opened this issue Jul 24, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@d180cf
Copy link

d180cf commented Jul 24, 2016

After upgrading from 1.8.10 to 2.0.0 got this error:

        add(layer: matrix | number, rand = () => Math.random()) {
            const v = this.outputs[this.outputs.length - 1];

            if (typeof layer === 'number') {
                this.add(matrix.make(layer, v.length, () => rand() / layer * 2));
            } else {
                this.weights.push(layer);
                this.outputs.push(vector.zero(layer.length));
            }
        }

In the rand() / layer * 2 expression layer has type matrix | number and thus tsc complains about the arithmetic operation. The <any> type cast works around the problem.

@mhegazy
Copy link
Contributor

mhegazy commented Jul 24, 2016

Duplicate of #7662

@mhegazy mhegazy added the Duplicate An existing issue was already created label Jul 24, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants