microsoft / microsoft/TypeScript
Weak callback parameters length check in js
Abierto
@sandersn ya está trabajando en esto.
Desde el 28/12/2020.
Experimentation Needed
Suggestion
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
TypeScript Version: 4.2.0-dev.20201222
Search Terms: callback parameters length
Code
in .ts everything is ok:
type Test = (a: number, b: number) => number
const a = (func: Test) => func
// OK
const b = a((d, e) => d + e)
// OK: Argument of type '(d: any, e: any, f: any) => any' is not assignable to parameter of type 'Test'
const c = a((d, e, f) => d + e + f)
in .js there's no error if parameters length is wrong:
/** @typedef {(a: number, b: number) => number} Test */
/** @type {(func: Test) => Test} */
const a = func => func
// OK
const b = a((d, e) => d + e)
// Actually: Parameter 'd' implicitly has an 'any' type.
// Expected: Argument of type '(d: any, e: any, f: any) => any' is not assignable to parameter of type 'Test'.
const c = a((d, e, f) => d + e + f)
Expected behavior:
Type checker to show the same error in .js file as in .ts file
Actual behavior:
No errors in .js file
Related Issues:
https://github.com/microsoft/TypeScript/issues/40205
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.
Evaluación
Este issue todavía no se ha evaluado.