question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Cosmos] Fix strictness issues across the package source code

See original GitHub issue

The cosmos package currently has in its tsconfig.json file strict:false which means there could be lingering issues related to accessing null and undefined values. You can read more about the value of turning on this mode here.

This issue is a follow up to https://github.com/Azure/azure-sdk-for-js/issues/5276.

  • Add a tsconfig.strict.json file that tracks which files yet to be fixed (Done).
  • Fix the following list of files:
    • documents/DatabaseAccount.ts
    • documents/IndexingPolicy.ts
    • plugins/Plugin.ts
    • common/helper.ts
    • common/uriFactory.ts
    • client/Conflict/Conflict.ts
    • client/Conflict/ConflictDefinition.ts
    • client/Conflict/ConflictResponse.ts
    • client/Conflict/Conflicts.ts
    • client/Container/Container.ts
    • client/Container/ContainerDefinition.ts
    • client/Container/ContainerRequest.ts
    • client/Container/ContainerResponse.ts
    • client/Container/Containers.ts
    • client/Database/Database.ts
    • client/Database/DatabaseResponse.ts
    • client/Database/Databases.ts
    • client/Item/Item.ts
    • client/Item/ItemResponse.ts
    • client/Item/Items.ts
    • client/Offer/Offer.ts
    • client/Offer/OfferResponse.ts
    • client/Offer/Offers.ts
    • client/Permission/Permission.ts
    • client/Permission/PermissionDefinition.ts
    • client/Permission/PermissionResponse.ts
    • client/Permission/Permissions.ts
    • client/Script/Scripts.ts
    • client/StoredProcedure/StoredProcedure.ts
    • client/StoredProcedure/StoredProcedureResponse.ts
    • client/StoredProcedure/StoredProcedures.ts
    • client/Trigger/Trigger.ts
    • client/Trigger/TriggerDefinition.ts
    • client/Trigger/TriggerResponse.ts
    • client/Trigger/Triggers.ts
    • client/User/User.ts
    • client/User/UserResponse.ts
    • client/User/Users.ts
    • client/UserDefinedFunction/UserDefinedFunction.ts
    • client/UserDefinedFunction/UserDefinedFunctionResponse.ts
    • client/UserDefinedFunction/UserDefinedFunctions.ts
    • queryExecutionContext/Aggregators/AverageAggregator.ts
    • queryExecutionContext/Aggregators/MaxAggregator.ts
    • queryExecutionContext/Aggregators/MinAggregator.ts
    • queryExecutionContext/Aggregators/SumAggregator.ts
    • queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts
    • queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts
    • queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts
    • queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts
    • queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts
    • queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts
    • queryExecutionContext/defaultQueryExecutionContext.ts
    • queryExecutionContext/documentProducer.ts
    • queryExecutionContext/ExecutionContext.ts
    • queryExecutionContext/headerUtils.ts
    • queryExecutionContext/orderByDocumentProducerComparator.ts
    • queryExecutionContext/orderByQueryExecutionContext.ts
    • queryExecutionContext/parallelQueryExecutionContext.ts
    • queryExecutionContext/parallelQueryExecutionContextBase.ts
    • queryExecutionContext/pipelinedQueryExecutionContext.ts
    • request/ErrorResponse.ts
    • request/FeedOptions.ts
    • request/FeedResponse.ts
    • request/request.ts
    • request/RequestContext.ts
    • request/RequestHandler.ts
    • request/RequestOptions.ts
    • request/ResourceResponse.ts
    • request/Response.ts
    • request/SharedOptions.ts
    • retry/defaultRetryPolicy.ts
    • retry/endpointDiscoveryRetryPolicy.ts
    • retry/resourceThrottleRetryPolicy.ts
    • retry/RetryPolicy.ts
    • retry/retryUtility.ts
    • retry/sessionRetryPolicy.ts
    • routing/CollectionRoutingMapFactory.ts
    • routing/inMemoryCollectionRoutingMap.ts
    • routing/partitionKeyRangeCache.ts
    • routing/QueryRange.ts
    • routing/smartRoutingMapProvider.ts
    • session/sessionContainer.ts
    • session/SessionContext.ts
    • session/VectorSessionToken.ts
    • utils/hashing/v1.ts
    • utils/hashing/v2.ts
    • utils/atob.browser.ts
    • utils/batch.ts
    • utils/digest.browser.ts
    • utils/encode.ts
    • utils/globalCrypto.ts
    • utils/headers.ts
    • utils/hmac.browser.ts
    • utils/offers.ts
    • utils/url.browser.ts
    • utils/url.ts
    • auth.ts
    • ChangeFeedIterator.ts
    • ChangeFeedResponse.ts
    • ClientContext.ts
    • CosmosClient.ts
    • CosmosClientOptions.ts
    • extractPartitionKey.ts
    • globalEndpointManager.ts
    • queryIterator.ts
    • client/User/index.ts
    • client/Item/index.ts
    • client/StoredProcedure/index.ts
    • client/Trigger/index.ts
    • client/Offer/index.ts
    • client/Permission/index.ts
    • client/index.ts
    • client/UserDefinedFunction/index.ts
    • client/Conflict/index.ts
    • client/Container/index.ts
    • client/Database/index.ts
    • documents/index.ts
    • request/index.ts
    • index.ts
    • retry/index.ts
    • queryExecutionContext/Aggregators/index.ts
    • queryExecutionContext/index.ts
    • common/index.ts
    • routing/index.ts

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
deyaaeldeencommented, Feb 8, 2022

@bzhang0 Thank you!

I noticed that the file was in the test/ subdirectory - not sure if this is an intended area for fixing.

Yes, we would like all code in this project to be compliant with the strictness rule. That being said, source files under test import the source files under src so the ones in src will have to be fixed first. Think of the source files as nodes in a graph where imports and exports between those files represent directed edges in that graph. To fix this strictness issue, we need to work our way up the graph along the export edges from the nodes that do not have any import edges. You might find cycles and those will have to be broken first. You could perhaps use tools like import-graph to help with this.

One thing I noticed when reading the errors from rushx build was that there were so many that I couldn’t see the relevant files, except for the ones in test/. Is there a way to see the errors for a specific file? Say I wanted to pinpoint my fixes on documents/DatabaseAccount.ts - how do I view the errors specific to that file?

You can redirect the stdout and stderr to a log file to have the whole list of errors saved there: rushx check:src:strict> log.txt 2>&1

Also, you can find a list with all the strictness issues in tsconfig.strict.json under the exclude field. You can take one file off that list to see what errors it causes.

PS rushx check:src:strict had a bug that was just fixed, so please make sure to rebase your branch on latest main.

1reaction
deyaaeldeencommented, Feb 4, 2022

@bzhang0 Thanks for taking on this issue, I can try to help with any questions you have.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error - Go Packages
Package errors provides a shared set of errors for use in the SDK, aliases functionality in the cosmossdk.io/errors module that used to be...
Read more >
JS/TS Tooling Overview
Overview of developer and build tools in the JavaScript and TypeScript ecosystem.
Read more >
Mayakumar | Lifelong Learning - WordPress.com
I like reading books. This blog is a platform for me to write about the books I read across various disciplines like software,...
Read more >
react-cosmos-source-map-example - npm package - Snyk
As a healthy sign for on-going project maintenance, we found that the GitHub repository had at least 1 pull request or issue interacted...
Read more >
M 3: semantic API migrations | Request PDF - ResearchGate
Previously researchers have also developed tools to perform library migrations or library updates at the source code level: (1) Xi et al.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found