microsoft / microsoft/TypeScript
Weak callback parameters length check in js
Aperta
@sandersn ci sta già lavorando.
Dal 28/12/2020.
Experimentation Needed
Suggestion
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.