Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Support compilation with strictNullChecks#214

Closed
sandersn wants to merge 1 commit intotensorflow:masterfrom
sandersn:allow-compilation-with-strictNullChecks
Closed

Support compilation with strictNullChecks#214
sandersn wants to merge 1 commit intotensorflow:masterfrom
sandersn:allow-compilation-with-strictNullChecks

Conversation

@sandersn
Copy link
Copy Markdown

@sandersn sandersn commented May 27, 2018

FEATURE

Currently, Sequential is not a valid subclass of Layer because its build method has type build(inputShape?: Shape | undefined) whereas Layer's build method has type build(inputShape: Shape | Shape[]). This breaks when trying to use Sequential in a project that has --strictNullChecks turned on for the Typescript compiler because Layer.build never expects undefined.

The most obvious fix is to make Layer.build's inputShape parameter optional as well. That's what I did, but I'm not sure it's correct -- I just started using tensorflow but ran into problems when I tried setting strictNullChecks to true.

The other fix would be to make Sequential.build have type build(inputShape: Shape) -- that is, to require the inputShape parameter. But it doesn't even use it, so this seems wrong.

Fixes tensorflow/tfjs#226


This change is Reviewable

Currently, Sequential is not a valid subclass of Layer because its build
method has type `build(inputShape?: Shape | undefined)` whereas
Layer's  build method has type `build(inputShape: Shape | Shape[])`.
This breaks when trying to use Sequential in a project that has
--strictNullChecks turned on for the Typescript compiler because
Layer.build never expects undefined.

The most obvious fix is to make Layer.build's inputShape parameter
optional as well. That's what I did, but I'm not sure it's correct -- I
*just* started using tensorflow but ran into problems when I tried
setting strictNullChecks to true.

The other fix would be to make Sequential.build have type
`build(inputShape: Shape)` -- that is, to require the inputShape
parameter. But it doesn't even use it, so this seems wrong.
@caisq
Copy link
Copy Markdown
Contributor

caisq commented May 27, 2018

Thanks, @sandersn . I'm closing this PR in favor of #215, which makes a couple of other minor improvements.

@caisq caisq closed this May 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile error in @tensorflow/tfjs-layers/dist/models.d.ts

2 participants