Writing MetadataOptions.properties.type function and object as ts types
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- tooling
Línea de trabajo
Start by reviewing the MetadataOptions property definitions and the transformation that produces JavaScript and .gen.d.ts files. Compare the proposed type-guessing and tsType approaches, then determine how specific function and object types should be represented in generated declarations while remaining simple at runtime. Done means the chosen approach is defined and supported consistently.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Currently, when defining properties of type function or object, only these type unsafe definitions are accepted.
The ability to define more specific types would greatly improve the quality and readability of the code.
I have 2 ideas in my mind how this could be achieved.
The first would be a more type guess based aproach like the following:
static readonly metadata: MetadataOptions = {
properties: {
someFunc: {
type: "(button: sap.m.Button) => void"
}
}
};
// the .gen.d.ts would look like this:
import { $ControlSettings } from "sap/ui/core/Control";
import Button from "sap/m/Button";
declare module "./Example" {
interface $ExampleSettings extends $ControlSettings {
callback?: (button: Button) => void
}
// ... //
}
The idea is to define them as type-safe TS types and convert them to the simple type with the transformation to js.
In the case of the example, the metadata would be rewritten to type: "function".
Alternatively, if guessing the type would be too difficult, since some object types can be very complex, enhancing the property with an additional key could make it easier and enable the useage of interfaces and named types:
static readonly metadata: MetadataOptions = {
properties: {
someFunc: {
tsType: "(button: sap.m.Button) => void",
type: "function"
}
}
};
This 2nd approach would also .
Here the tsType would be used for the gen.d.ts file and removed in the js transformation as it's not needed anymore.
It's not often that i need to use these property types but when I do, it's follow by unnessecary assertion of types.
- Lenguaje dominante
- TypeScript
- Estrellas
- 213
- Forks
- 35
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de UI5/typescript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
UI5/typescript#625 · 4 comentarios ·
-
dts-generator
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
UI5/typescript#529 · 3 comentarios ·
-
Dependency DashboardAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
UI5/typescript#587 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
UI5/typescript#532 ·
-
enhancement ts-interface-generator
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
UI5/typescript#524 ·
Todos los issues de UI5/typescript
Issues similares
-
combobox: highlighted item never scrolls into view when there's no content part (Ark Command)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
bug P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día