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

ServerConfig.d.ts: add types for options #7328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pjonsson
Copy link
Contributor

What this PR does

Add some types for the options in
ServerConfig. This uncovered a missing
check in sendFeedback.

Test me

Tested by CI.

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

Add some types for the options in
ServerConfig. This uncovered a missing
check in sendFeedback.
declare class ServerConfig {
config: unknown;
init(serverConfigUrl: string): Promise<unknown>;
config: ServerConfigOptions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not for this PR, but I find the ServerConfig design a bit puzzling, the object caches a configuration, but ServerConfig.init() that uses the cached configuration is only called from Terria.start(), and that call is always done directly after new ServerConfig(). To me, it seems it would have been easier to have ServerConfig.init() be the equivalent of a static function in other languages so ServerConfig object would never have to be allocated at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

This way server endpoint will be called only once, or do you mean about the server config stored in the terria class?

@@ -167,7 +167,7 @@ export interface ConfigParameters {
* @deprecated
*/
proxyableDomainsUrl?: string;
serverConfigUrl?: string;
serverConfigUrl: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe serverConfigUrl should be optional as it's non-required property, and terria can work without having terriajs-server

newShareUrlPrefix?: string;
shareUrlPrefixes: object;
additionalFeedbackParameters: object[];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

p.s. It might be better to define this interface in terriajs-server, but from the top of my head, I am not sure if it is possible.

shareUrlPrefixes: object;
additionalFeedbackParameters: object[];
}

declare class ServerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about converting the entire ServerConfig class to typescript? it is relatively small and it would be easier then to have an additional declaration file

declare class ServerConfig {
config: unknown;
init(serverConfigUrl: string): Promise<unknown>;
config: ServerConfigOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

This way server endpoint will be called only once, or do you mean about the server config stored in the terria class?

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.

2 participants