Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript .then()的返回类型是否为即使没有返回语句的承诺?_Javascript_Typescript_Ecmascript 6_Promise_Es6 Promise - Fatal编程技术网

Javascript .then()的返回类型是否为即使没有返回语句的承诺?

Javascript .then()的返回类型是否为即使没有返回语句的承诺?,javascript,typescript,ecmascript-6,promise,es6-promise,Javascript,Typescript,Ecmascript 6,Promise,Es6 Promise,for.then()表示then的返回类型是承诺 所以我的问题是,以下代码块之间有区别吗 var promise1=新承诺(函数(解析、拒绝){ 决心(“成功!”); }); 承诺1.然后(功能(价值){ console.log(值); //此处未指定返回类型 });如果未从处理程序中返回任何内容,则()下一步将使用未定义的值自动解析。因此,在功能上,这两个示例都是相同的,因为它们都解析任何使用未定义值链接到它们的.then()处理程序。从结构上讲,第二个示例将在链中嵌套一个额外的承诺。关于t

for.then()表示then的返回类型是承诺

所以我的问题是,以下代码块之间有区别吗

var promise1=新承诺(函数(解析、拒绝){
决心(“成功!”);
});
承诺1.然后(功能(价值){
console.log(值);
//此处未指定返回类型

});
如果未从
处理程序中返回任何内容,则()下一步将使用未定义的值自动解析。因此,在功能上,这两个示例都是相同的,因为它们都解析任何使用未定义值链接到它们的
.then()
处理程序。从结构上讲,第二个示例将在链中嵌套一个额外的承诺。关于typescript问题,我有一种预感,要么您使用非本地承诺,要么您正在编译为非本地承诺。非常感谢@Shilly。让我非常清楚:)