Open Bene-Graham opened 5 years ago
According to https://docs.microsoft.com/de-de/javascript/api/@azure/storage-blob/iblockblobuploadoptions?view=azure-node-preview blobHTTPHeaders
is an optional property on azure.IBlockBlobUploadOptions
.
You told TypeScript that options
is of type azure.IBlockBlobUploadOptions
, which means that options.blobHTTPHeaders
is optional. Whether you assign an object to it that has blobHTTPHeaders
doesn't matter in that case. options.blobHTTPHeaders
is not narrowed to "not undefined" in your code.
You can solve the problem by explicitly telling TypeScript how options
looks like - in your case it is a { blobHTTPHeaders: BlobHTTPHeaders}
.
On 2nd thought, this seems to be a duplicate of https://github.com/Microsoft/TypeScript/issues/20219
TypeScript Version: 3.5.0-dev.20190501
Search Terms: strict false positive object
Code
tsconfig
Expected behavior:
since when the creating the
options
variable the propertyblobHTTPHeaders
is also defined. I would expect that accessing properties off ofblobHTTPHeaders
should not throw a "Object is possibly 'undefined'."Actual behavior:
Getting Object is possibly 'undefined'.
Playground Link:
Related Issues: