mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
refactor: add better types to field configs (#6317)
* fix: add config types in all fields * fix: add interfaces to fromJson * chore: cleanup from cherry-pick * chore: add docs to exported properties * chore: format * chore: remove unnecessary test case * fix: replacing message references in tooltip * chore: fix format * chore: rename interfaces to be more explicit * chore: format * fix: add proper visibility keywords * chore: fix label field config name * chore: formatting * chore: remove unnecessarily renamed imports
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
import * as goog from '../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.FieldLabelSerializable');
|
||||
|
||||
import {FieldLabel} from './field_label.js';
|
||||
import {FieldLabelConfig, FieldLabelFromJsonConfig, FieldLabel} from './field_label.js';
|
||||
import * as fieldRegistry from './field_registry.js';
|
||||
import * as parsing from './utils/parsing.js';
|
||||
|
||||
@@ -52,7 +52,7 @@ export class FieldLabelSerializable extends FieldLabel {
|
||||
* for a list of properties this parameter supports.
|
||||
*/
|
||||
constructor(
|
||||
opt_value?: string, opt_class?: string, opt_config?: AnyDuringMigration) {
|
||||
opt_value?: string, opt_class?: string, opt_config?: FieldLabelConfig) {
|
||||
super(String(opt_value ?? ''), opt_class, opt_config);
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ export class FieldLabelSerializable extends FieldLabel {
|
||||
* @nocollapse
|
||||
* @internal
|
||||
*/
|
||||
static override fromJson(options: AnyDuringMigration):
|
||||
static override fromJson(options: FieldLabelFromJsonConfig):
|
||||
FieldLabelSerializable {
|
||||
const text = parsing.replaceMessageReferences(options['text']);
|
||||
const text = parsing.replaceMessageReferences(options.text);
|
||||
// `this` might be a subclass of FieldLabelSerializable if that class
|
||||
// doesn't override the static fromJson method.
|
||||
return new this(text, undefined, options);
|
||||
|
||||
Reference in New Issue
Block a user