Skip to content

Conversation

shakyShane
Copy link
Collaborator

Reviewer:
Asana:

Description

Steps to test

Comment on lines +12 to 18
* @typedef {import("./deviceApiCalls/__generated__/validators-ts").BaseRuntimeConfiguration} BaseRuntimeConfiguration
* @typedef {{
* contentScope: import("@duckduckgo/privacy-configuration/schema/config").ConfigV4<number>;
* userPreferences: BaseRuntimeConfiguration['userPreferences'];
* userUnprotectedDomains: BaseRuntimeConfiguration['userUnprotectedDomains'];
* }} RuntimeConfiguration
* @typedef {import("../packages/device-api").DeviceApi} DeviceApi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just define RuntimeConfiguration here, using some types from schemas, and some from privacy-configuration repo

"type": "object",
"additionalProperties": false,
"title": "RuntimeConfiguration",
"title": "BaseRuntimeConfiguration",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this is just used as a base type, and never directly

// Also we might not need zod anymore for defining runtime config? We should simply rely on the
// C-S-S types.
// @ts-ignore - TODO: C-S-S must be migrated to use the config from privacy-configuration
const enabled = autofillEnabled(runtimeConfig);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't needed with my change, but in general if you need to silence a TS error just do it on a variable level, to prevent disabling the type-checker for the entire line, eg:

const runtimeConfigAsAny = /** @type {any} */(runtimeConfig)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah, we talked it, thanks! Will update.

Comment on lines +58 to 61
const contentScopeAsAny = /** @type {any} */ (contentScope);
const cssUserPreferences = /** @type {any} */ (userPreferences);
const processedConfig = processConfig(contentScopeAsAny, userUnprotectedDomains, cssUserPreferences);
return isAutofillEnabledFromProcessedConfig(processedConfig);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we interface with an external lib (css) where the types are incorrect. so, the temporary solution is to set the vars as any instead of ts-ignore

Comment on lines +150 to +154
/**
* This casting is done to erase the 'unknown' type for `contentScope`, since it now
* comes from the privacy-configuration repo
*/
this._runtimeConfiguration = /** @type {RuntimeConfiguration} */ (/** @type {any} */ runtimeConfig);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is like the as unknown as <type> trick in TS

/**
* @param {GlobalConfig} globalConfig
* @returns {{success: import('../__generated__/validators-ts').RuntimeConfiguration}}
* @returns {{success: import('../../Settings.js').RuntimeConfiguration}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we can import the type we made manually.

@dbajpeyi dbajpeyi force-pushed the dbajpeyi/chore-bumo-c-s-s-3 branch 3 times, most recently from c057232 to 590dd7c Compare March 28, 2025 11:18
@dbajpeyi dbajpeyi force-pushed the dbajpeyi/chore-bumo-c-s-s-3 branch from 6ee99c8 to f37b4b3 Compare April 4, 2025 09:49
@dbajpeyi dbajpeyi force-pushed the dbajpeyi/chore-bumo-c-s-s-3 branch 6 times, most recently from 2fe6954 to 6626710 Compare April 8, 2025 10:57
Base automatically changed from dbajpeyi/chore-bumo-c-s-s-3 to main April 10, 2025 07:00
@borgateo
Copy link
Contributor

borgateo commented Jul 2, 2025

@shakyShane, @dbajpeyi Are you planning to continue working on this PR?
Any objections if I close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants