Skip to content
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

refactor: enable record undefined checks #66

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmd-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const add = async function (

if (version === undefined)
throw new Error("Could not determine package version to add");
const versionInfo = pkgInfo.versions[version];
const versionInfo = pkgInfo.versions[version]!;
// verify editor version
if (versionInfo.unity) {
const requiredEditorVersion = versionInfo.unityRelease
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const getTableRow = function (pkg: SearchedPkgInfo): TableRow {
const name = pkg.name;
const version = tryGetLatestVersion(pkg);
let date = "";
if (pkg.time && pkg.time.modified) date = pkg.time.modified.split("T")[0];
if (pkg.time && pkg.time.modified) date = pkg.time.modified.split("T")[0]!;
if (pkg.date) {
date = pkg.date.toISOString().slice(0, 10);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const printInfo = function (pkg: PkgInfo) {
const versionCount = Object.keys(pkg.versions).length;
const ver = tryGetLatestVersion(pkg);
assert(ver !== undefined);
const verInfo = pkg.versions[ver];
const verInfo = pkg.versions[ver]!;
const license = verInfo.license || "proprietary or unlicensed";
const displayName = verInfo.displayName;
const description = verInfo.description || pkg.description;
Expand Down
2 changes: 1 addition & 1 deletion src/registry-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const fetchPackageDependencies = async function (
// add dependencies to pending list
if (depObj.self || deep) {
const deps: NameVersionPair[] = (
_.toPairs(pkgInfo.versions[entry.version]["dependencies"]) as [
_.toPairs(pkgInfo.versions[entry.version]!["dependencies"]) as [
DomainName,
SemanticVersion
][]
Expand Down
2 changes: 1 addition & 1 deletion src/types/domain-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function namespaceFor(hostname: string): DomainName {
// 2-part domains, like unity.com
if (count < 3) return segments;
// Domains with two short extensions like my-school.ac.at
if (segments[count - 1].length <= 3 && segments[count - 2].length <= 3)
if (segments[count - 1]!.length <= 3 && segments[count - 2]!.length <= 3)
return segments.slice(count - 3);
// Domains with one extension such as registry.npmjs.org
return segments.slice(count - 2);
Expand Down
4 changes: 2 additions & 2 deletions src/types/editor-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const compareEditorVersion = function (
const arrA = editorVersionToArray(verA);
const arrB = editorVersionToArray(verB);
for (let i = 0; i < arrA.length; i++) {
const valA = arrA[i];
const valB = arrB[i];
const valA = arrA[i]!;
const valB = arrB[i]!;
if (valA > valB) return 1;
else if (valA < valB) return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export function trySplitAtFirstOccurrenceOf(
): [string, string | undefined] {
const elements = s.split(split);
if (elements.length === 1) return [s, undefined];
return [elements[0], elements.slice(1).join(split)];
return [elements[0]!, elements.slice(1).join(split)];
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
"noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
Expand Down