π Search Terms
uninitialized function - uninitialized - uninitialized function call
β
Viability Checklist
β Suggestion
This is a request to add a new configuration flag that makes typescript error when an uninitialized function is called within the same scope
This is a comment made by Ryan Cavanaugh (@RyanCavanaugh) on a similar topic (using an uninitialized variable) for why an error is not thrown by typescript in the case of using an uninitialized variable (not calling a function)
There are more comments on this topic
But the same argument of why function parameters assignment is contra-variant applies to why throw an error when an uninitialized function is called. Typescript doesn't know if it will surely error but it prevents it anyway
π Motivating Example
The below is a case of a runtime error thrown by calling an uninitialized variable which typescript didn't prevent
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABAMXBAjIgFKSAubASgF4A+ANzhgBNCBvAKEWcVwi0MQHovEoALGAGc+-AE5wA7iICGiMeFgBbAKaIVYiWKYsxKqCDFI65GQBsQKggCYAvg3sM2sBIgDm+gHIrJqSEURGFnl9QyQORDJECAQhODMVADozODcsAANvXzR0wgcGBh4YsCEoQNMLFVtIlDR0LDAfPwhOHnUADwAHFWgVakQAIxV+GXJ4MQIBYVEJaUQ5KABPbqEIMRhOso0tRE69chUwWDA3eUUYVXVNODEhBmb6jjI6REbsyAjbVt5wFS6eqB9QbDUbjSaCETUOAqIRgADkZQEs3mfGWMLWGy21zEiEkggg-EQCRk1BEUDgKIURwuam2NwKxVKryaaBqHigWWaHCAA
π» Use Cases
- What do you want to use this for? Preventing runtime errors
- What shortcomings exist with current approaches? none
- What workarounds are you using in the meantime?
π Search Terms
uninitialized function - uninitialized - uninitialized function call
β Viability Checklist
β Suggestion
This is a request to add a new configuration flag that makes typescript error when an uninitialized function is called within the same scope
This is a comment made by Ryan Cavanaugh (@RyanCavanaugh) on a similar topic (using an uninitialized variable) for why an error is not thrown by typescript in the case of using an uninitialized variable (not calling a function)
There are more comments on this topic
But the same argument of why function parameters assignment is contra-variant applies to why throw an error when an uninitialized function is called. Typescript doesn't know if it will surely error but it prevents it anyway
π Motivating Example
The below is a case of a runtime error thrown by calling an uninitialized variable which typescript didn't prevent
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABAMXBAjIgFKSAubASgF4A+ANzhgBNCBvAKEWcVwi0MQHovEoALGAGc+-AE5wA7iICGiMeFgBbAKaIVYiWKYsxKqCDFI65GQBsQKggCYAvg3sM2sBIgDm+gHIrJqSEURGFnl9QyQORDJECAQhODMVADozODcsAANvXzR0wgcGBh4YsCEoQNMLFVtIlDR0LDAfPwhOHnUADwAHFWgVakQAIxV+GXJ4MQIBYVEJaUQ5KABPbqEIMRhOso0tRE69chUwWDA3eUUYVXVNODEhBmb6jjI6REbsyAjbVt5wFS6eqB9QbDUbjSaCETUOAqIRgADkZQEs3mfGWMLWGy21zEiEkggg-EQCRk1BEUDgKIURwuam2NwKxVKryaaBqHigWWaHCAA
π» Use Cases