mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Merge branch 'master' into refactorNarrowTypeByInstanceOf
This commit is contained in:
38
bin/tsc.js
38
bin/tsc.js
@@ -13005,15 +13005,30 @@ var ts;
|
||||
return type;
|
||||
}
|
||||
var prototypeProperty = getPropertyOfType(rightType, "prototype");
|
||||
if (!prototypeProperty) {
|
||||
return type;
|
||||
if (prototypeProperty) {
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (targetType !== anyType) {
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
var constructSignatures;
|
||||
if (rightType.flags & 2048) {
|
||||
constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures;
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
else if (rightType.flags & 32768) {
|
||||
constructSignatures = getSignaturesOfType(rightType, 1);
|
||||
}
|
||||
if (constructSignatures && constructSignatures.length !== 0) {
|
||||
var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); }));
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); }));
|
||||
}
|
||||
return instanceType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -23260,15 +23275,6 @@ var ts;
|
||||
scopeEmitEnd();
|
||||
if (thisNodeIsDecorated) {
|
||||
write(";");
|
||||
if (node.name) {
|
||||
writeLine();
|
||||
write("Object.defineProperty(");
|
||||
emitDeclarationName(node);
|
||||
write(", \"name\", { value: \"");
|
||||
emitDeclarationName(node);
|
||||
write("\", configurable: true });");
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
if (isClassExpressionWithStaticProperties) {
|
||||
for (var _a = 0; _a < staticProperties.length; _a++) {
|
||||
|
||||
@@ -13389,15 +13389,30 @@ var ts;
|
||||
return type;
|
||||
}
|
||||
var prototypeProperty = getPropertyOfType(rightType, "prototype");
|
||||
if (!prototypeProperty) {
|
||||
return type;
|
||||
if (prototypeProperty) {
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (targetType !== anyType) {
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
var constructSignatures;
|
||||
if (rightType.flags & 2048) {
|
||||
constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures;
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
else if (rightType.flags & 32768) {
|
||||
constructSignatures = getSignaturesOfType(rightType, 1);
|
||||
}
|
||||
if (constructSignatures && constructSignatures.length !== 0) {
|
||||
var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); }));
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); }));
|
||||
}
|
||||
return instanceType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -23644,15 +23659,6 @@ var ts;
|
||||
scopeEmitEnd();
|
||||
if (thisNodeIsDecorated) {
|
||||
write(";");
|
||||
if (node.name) {
|
||||
writeLine();
|
||||
write("Object.defineProperty(");
|
||||
emitDeclarationName(node);
|
||||
write(", \"name\", { value: \"");
|
||||
emitDeclarationName(node);
|
||||
write("\", configurable: true });");
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
if (isClassExpressionWithStaticProperties) {
|
||||
for (var _a = 0; _a < staticProperties.length; _a++) {
|
||||
|
||||
@@ -15732,17 +15732,34 @@ var ts;
|
||||
}
|
||||
// Target type is type of prototype property
|
||||
var prototypeProperty = getPropertyOfType(rightType, "prototype");
|
||||
if (!prototypeProperty) {
|
||||
return type;
|
||||
if (prototypeProperty) {
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (targetType !== anyType) {
|
||||
// Narrow to the target type if it's a subtype of the current type
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
// If the current type is a union type, remove all constituents that aren't subtypes of the target.
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
// Narrow to target type if it is a subtype of current type
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
// Target type is type of construct signature
|
||||
var constructSignatures;
|
||||
if (rightType.flags & 2048 /* Interface */) {
|
||||
constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures;
|
||||
}
|
||||
// If current type is a union type, remove all constituents that aren't subtypes of target type
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
else if (rightType.flags & 32768 /* Anonymous */) {
|
||||
constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */);
|
||||
}
|
||||
if (constructSignatures && constructSignatures.length !== 0) {
|
||||
var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); }));
|
||||
// Pickup type from union types
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); }));
|
||||
}
|
||||
return instanceType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -27577,6 +27594,7 @@ var ts;
|
||||
writeLine();
|
||||
emitToken(15 /* CloseBraceToken */, node.members.end);
|
||||
scopeEmitEnd();
|
||||
// TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now.
|
||||
// For a decorated class, we need to assign its name (if it has one). This is because we emit
|
||||
// the class as a class expression to avoid the double-binding of the identifier:
|
||||
//
|
||||
@@ -27586,15 +27604,6 @@ var ts;
|
||||
//
|
||||
if (thisNodeIsDecorated) {
|
||||
write(";");
|
||||
if (node.name) {
|
||||
writeLine();
|
||||
write("Object.defineProperty(");
|
||||
emitDeclarationName(node);
|
||||
write(", \"name\", { value: \"");
|
||||
emitDeclarationName(node);
|
||||
write("\", configurable: true });");
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
// Emit static property assignment. Because classDeclaration is lexically evaluated,
|
||||
// it is safe to emit static property assignment after classDeclaration
|
||||
|
||||
@@ -15732,17 +15732,34 @@ var ts;
|
||||
}
|
||||
// Target type is type of prototype property
|
||||
var prototypeProperty = getPropertyOfType(rightType, "prototype");
|
||||
if (!prototypeProperty) {
|
||||
return type;
|
||||
if (prototypeProperty) {
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
if (targetType !== anyType) {
|
||||
// Narrow to the target type if it's a subtype of the current type
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
// If the current type is a union type, remove all constituents that aren't subtypes of the target.
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
// Narrow to target type if it is a subtype of current type
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
// Target type is type of construct signature
|
||||
var constructSignatures;
|
||||
if (rightType.flags & 2048 /* Interface */) {
|
||||
constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures;
|
||||
}
|
||||
// If current type is a union type, remove all constituents that aren't subtypes of target type
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, targetType); }));
|
||||
else if (rightType.flags & 32768 /* Anonymous */) {
|
||||
constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */);
|
||||
}
|
||||
if (constructSignatures && constructSignatures.length !== 0) {
|
||||
var instanceType = getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); }));
|
||||
// Pickup type from union types
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.filter(type.types, function (t) { return isTypeSubtypeOf(t, instanceType); }));
|
||||
}
|
||||
return instanceType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -27577,6 +27594,7 @@ var ts;
|
||||
writeLine();
|
||||
emitToken(15 /* CloseBraceToken */, node.members.end);
|
||||
scopeEmitEnd();
|
||||
// TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now.
|
||||
// For a decorated class, we need to assign its name (if it has one). This is because we emit
|
||||
// the class as a class expression to avoid the double-binding of the identifier:
|
||||
//
|
||||
@@ -27586,15 +27604,6 @@ var ts;
|
||||
//
|
||||
if (thisNodeIsDecorated) {
|
||||
write(";");
|
||||
if (node.name) {
|
||||
writeLine();
|
||||
write("Object.defineProperty(");
|
||||
emitDeclarationName(node);
|
||||
write(", \"name\", { value: \"");
|
||||
emitDeclarationName(node);
|
||||
write("\", configurable: true });");
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
// Emit static property assignment. Because classDeclaration is lexically evaluated,
|
||||
// it is safe to emit static property assignment after classDeclaration
|
||||
|
||||
@@ -3898,6 +3898,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
|
||||
scopeEmitEnd();
|
||||
|
||||
// TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now.
|
||||
|
||||
// For a decorated class, we need to assign its name (if it has one). This is because we emit
|
||||
// the class as a class expression to avoid the double-binding of the identifier:
|
||||
//
|
||||
@@ -3907,15 +3909,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
//
|
||||
if (thisNodeIsDecorated) {
|
||||
write(";");
|
||||
if (node.name) {
|
||||
writeLine();
|
||||
write("Object.defineProperty(");
|
||||
emitDeclarationName(node);
|
||||
write(", \"name\", { value: \"");
|
||||
emitDeclarationName(node);
|
||||
write("\", configurable: true });");
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
// Emit static property assignment. Because classDeclaration is lexically evaluated,
|
||||
|
||||
2
src/lib/es6.d.ts
vendored
2
src/lib/es6.d.ts
vendored
@@ -3580,6 +3580,7 @@ interface PromiseLike<T> {
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3593,6 +3594,7 @@ interface Promise<T> {
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
|
||||
@@ -1632,7 +1632,7 @@ module ts {
|
||||
private fileNameToEntry: Map<HostFileInformation>;
|
||||
private _compilationSettings: CompilerOptions;
|
||||
|
||||
constructor(private host: LanguageServiceHost) {
|
||||
constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) {
|
||||
// script id => script index
|
||||
this.fileNameToEntry = {};
|
||||
|
||||
@@ -1650,6 +1650,10 @@ module ts {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
private normalizeFileName(fileName: string): string {
|
||||
return this.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
}
|
||||
|
||||
private createEntry(fileName: string) {
|
||||
let entry: HostFileInformation;
|
||||
let scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
@@ -1661,15 +1665,15 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
return this.fileNameToEntry[normalizeSlashes(fileName)] = entry;
|
||||
return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry;
|
||||
}
|
||||
|
||||
public getEntry(fileName: string): HostFileInformation {
|
||||
return lookUp(this.fileNameToEntry, normalizeSlashes(fileName));
|
||||
private getEntry(fileName: string): HostFileInformation {
|
||||
return lookUp(this.fileNameToEntry, this.normalizeFileName(fileName));
|
||||
}
|
||||
|
||||
public contains(fileName: string): boolean {
|
||||
return hasProperty(this.fileNameToEntry, normalizeSlashes(fileName));
|
||||
private contains(fileName: string): boolean {
|
||||
return hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName));
|
||||
}
|
||||
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
@@ -1684,8 +1688,10 @@ module ts {
|
||||
let fileNames: string[] = [];
|
||||
|
||||
forEachKey(this.fileNameToEntry, key => {
|
||||
if (hasProperty(this.fileNameToEntry, key) && this.fileNameToEntry[key])
|
||||
fileNames.push(key);
|
||||
let entry = this.getEntry(key);
|
||||
if (entry) {
|
||||
fileNames.push(entry.hostFileName);
|
||||
}
|
||||
});
|
||||
|
||||
return fileNames;
|
||||
@@ -2387,7 +2393,7 @@ module ts {
|
||||
|
||||
function synchronizeHostData(): void {
|
||||
// Get a fresh cache of the host information
|
||||
let hostCache = new HostCache(host);
|
||||
let hostCache = new HostCache(host, getCanonicalFileName);
|
||||
|
||||
// If the program is already up-to-date, we can reuse it
|
||||
if (programUpToDate()) {
|
||||
@@ -2408,7 +2414,7 @@ module ts {
|
||||
let newProgram = createProgram(hostCache.getRootFileNames(), newSettings, {
|
||||
getSourceFile: getOrCreateSourceFile,
|
||||
getCancellationToken: () => cancellationToken,
|
||||
getCanonicalFileName: (fileName) => useCaseSensitivefileNames ? fileName : fileName.toLowerCase(),
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
||||
getNewLine: () => host.getNewLine ? host.getNewLine() : "\r\n",
|
||||
getDefaultLibFileName: (options) => host.getDefaultLibFileName(options),
|
||||
|
||||
@@ -21,7 +21,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
function decorate() { }
|
||||
let Decorated = class {
|
||||
};
|
||||
Object.defineProperty(Decorated, "name", { value: "Decorated", configurable: true });
|
||||
Decorated = __decorate([
|
||||
decorate
|
||||
], Decorated);
|
||||
|
||||
43
tests/baselines/reference/promiseVoidErrorCallback.js
Normal file
43
tests/baselines/reference/promiseVoidErrorCallback.js
Normal file
@@ -0,0 +1,43 @@
|
||||
//// [promiseVoidErrorCallback.ts]
|
||||
interface T1 {
|
||||
__t1: string;
|
||||
}
|
||||
|
||||
interface T2 {
|
||||
__t2: string;
|
||||
}
|
||||
|
||||
interface T3 {
|
||||
__t3: string;
|
||||
}
|
||||
|
||||
function f1(): Promise<T1> {
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
}
|
||||
|
||||
function f2(x: T1): T2 {
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
}
|
||||
|
||||
var x3 = f1()
|
||||
.then(f2, (e: Error) => {
|
||||
throw e;
|
||||
})
|
||||
.then((x: T2) => {
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
});
|
||||
|
||||
//// [promiseVoidErrorCallback.js]
|
||||
function f1() {
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
}
|
||||
function f2(x) {
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
}
|
||||
var x3 = f1()
|
||||
.then(f2, (e) => {
|
||||
throw e;
|
||||
})
|
||||
.then((x) => {
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
});
|
||||
75
tests/baselines/reference/promiseVoidErrorCallback.symbols
Normal file
75
tests/baselines/reference/promiseVoidErrorCallback.symbols
Normal file
@@ -0,0 +1,75 @@
|
||||
=== tests/cases/compiler/promiseVoidErrorCallback.ts ===
|
||||
interface T1 {
|
||||
>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0))
|
||||
|
||||
__t1: string;
|
||||
>__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 0, 14))
|
||||
}
|
||||
|
||||
interface T2 {
|
||||
>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1))
|
||||
|
||||
__t2: string;
|
||||
>__t2 : Symbol(__t2, Decl(promiseVoidErrorCallback.ts, 4, 14))
|
||||
}
|
||||
|
||||
interface T3 {
|
||||
>T3 : Symbol(T3, Decl(promiseVoidErrorCallback.ts, 6, 1))
|
||||
|
||||
__t3: string;
|
||||
>__t3 : Symbol(__t3, Decl(promiseVoidErrorCallback.ts, 8, 14))
|
||||
}
|
||||
|
||||
function f1(): Promise<T1> {
|
||||
>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11))
|
||||
>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0))
|
||||
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, 4769, 1), Decl(lib.d.ts, 4854, 11))
|
||||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4836, 39), Decl(lib.d.ts, 4843, 54))
|
||||
>__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28))
|
||||
}
|
||||
|
||||
function f2(x: T1): T2 {
|
||||
>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1))
|
||||
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 16, 12))
|
||||
>T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0))
|
||||
>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1))
|
||||
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
>__t2 : Symbol(__t2, Decl(promiseVoidErrorCallback.ts, 17, 12))
|
||||
>x.__t1 : Symbol(T1.__t1, Decl(promiseVoidErrorCallback.ts, 0, 14))
|
||||
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 16, 12))
|
||||
>__t1 : Symbol(T1.__t1, Decl(promiseVoidErrorCallback.ts, 0, 14))
|
||||
}
|
||||
|
||||
var x3 = f1()
|
||||
>x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3))
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158))
|
||||
>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158))
|
||||
>f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1))
|
||||
|
||||
.then(f2, (e: Error) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158))
|
||||
>f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1))
|
||||
>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15))
|
||||
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
|
||||
|
||||
throw e;
|
||||
>e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15))
|
||||
|
||||
})
|
||||
.then((x: T2) => {
|
||||
>then : Symbol(Promise.then, Decl(lib.d.ts, 4774, 22), Decl(lib.d.ts, 4781, 158))
|
||||
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11))
|
||||
>T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1))
|
||||
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
>__t3 : Symbol(__t3, Decl(promiseVoidErrorCallback.ts, 25, 12))
|
||||
>x.__t2 : Symbol(T2.__t2, Decl(promiseVoidErrorCallback.ts, 4, 14))
|
||||
>x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11))
|
||||
>__t2 : Symbol(T2.__t2, Decl(promiseVoidErrorCallback.ts, 4, 14))
|
||||
|
||||
});
|
||||
89
tests/baselines/reference/promiseVoidErrorCallback.types
Normal file
89
tests/baselines/reference/promiseVoidErrorCallback.types
Normal file
@@ -0,0 +1,89 @@
|
||||
=== tests/cases/compiler/promiseVoidErrorCallback.ts ===
|
||||
interface T1 {
|
||||
>T1 : T1
|
||||
|
||||
__t1: string;
|
||||
>__t1 : string
|
||||
}
|
||||
|
||||
interface T2 {
|
||||
>T2 : T2
|
||||
|
||||
__t2: string;
|
||||
>__t2 : string
|
||||
}
|
||||
|
||||
interface T3 {
|
||||
>T3 : T3
|
||||
|
||||
__t3: string;
|
||||
>__t3 : string
|
||||
}
|
||||
|
||||
function f1(): Promise<T1> {
|
||||
>f1 : () => Promise<T1>
|
||||
>Promise : Promise<T>
|
||||
>T1 : T1
|
||||
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
>Promise.resolve({ __t1: "foo_t1" }) : Promise<{ __t1: string; }>
|
||||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>Promise : PromiseConstructor
|
||||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>{ __t1: "foo_t1" } : { __t1: string; }
|
||||
>__t1 : string
|
||||
>"foo_t1" : string
|
||||
}
|
||||
|
||||
function f2(x: T1): T2 {
|
||||
>f2 : (x: T1) => T2
|
||||
>x : T1
|
||||
>T1 : T1
|
||||
>T2 : T2
|
||||
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
>{ __t2: x.__t1 + ":foo_21" } : { __t2: string; }
|
||||
>__t2 : string
|
||||
>x.__t1 + ":foo_21" : string
|
||||
>x.__t1 : string
|
||||
>x : T1
|
||||
>__t1 : string
|
||||
>":foo_21" : string
|
||||
}
|
||||
|
||||
var x3 = f1()
|
||||
>x3 : Promise<{ __t3: string; }>
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }>
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) .then : { <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>f1() .then(f2, (e: Error) => { throw e;}) : Promise<T2>
|
||||
>f1() .then : { <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>f1() : Promise<T1>
|
||||
>f1 : () => Promise<T1>
|
||||
|
||||
.then(f2, (e: Error) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T1) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>f2 : (x: T1) => T2
|
||||
>(e: Error) => { throw e;} : (e: Error) => void
|
||||
>e : Error
|
||||
>Error : Error
|
||||
|
||||
throw e;
|
||||
>e : Error
|
||||
|
||||
})
|
||||
.then((x: T2) => {
|
||||
>then : { <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: T2) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
|
||||
>(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; }
|
||||
>x : T2
|
||||
>T2 : T2
|
||||
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
>{ __t3: x.__t2 + "bar" } : { __t3: string; }
|
||||
>__t3 : string
|
||||
>x.__t2 + "bar" : string
|
||||
>x.__t2 : string
|
||||
>x : T2
|
||||
>__t2 : string
|
||||
>"bar" : string
|
||||
|
||||
});
|
||||
28
tests/cases/compiler/promiseVoidErrorCallback.ts
Normal file
28
tests/cases/compiler/promiseVoidErrorCallback.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
//@target: ES6
|
||||
interface T1 {
|
||||
__t1: string;
|
||||
}
|
||||
|
||||
interface T2 {
|
||||
__t2: string;
|
||||
}
|
||||
|
||||
interface T3 {
|
||||
__t3: string;
|
||||
}
|
||||
|
||||
function f1(): Promise<T1> {
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
}
|
||||
|
||||
function f2(x: T1): T2 {
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
}
|
||||
|
||||
var x3 = f1()
|
||||
.then(f2, (e: Error) => {
|
||||
throw e;
|
||||
})
|
||||
.then((x: T2) => {
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
});
|
||||
Reference in New Issue
Block a user