Merge branch 'release-2.0_fix10625' into release-2.0
This commit is contained in:
commit
93e0451b5d
9 changed files with 99 additions and 8 deletions
|
@ -2150,9 +2150,14 @@ namespace ts {
|
|||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags);
|
||||
}
|
||||
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) {
|
||||
if (type.flags & TypeFlags.Anonymous || !(flags & TypeFormatFlags.UseTypeAliasValue)) {
|
||||
const typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
}
|
||||
else {
|
||||
writeUnionOrIntersectionType(<UnionOrIntersectionType>type, nextFlags);
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.UnionOrIntersection) {
|
||||
writeUnionOrIntersectionType(<UnionOrIntersectionType>type, nextFlags);
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
errorNameNode = declaration.name;
|
||||
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
|
||||
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
errorNameNode = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
errorNameNode = signature.name;
|
||||
resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
|
||||
resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
errorNameNode = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ namespace ts {
|
|||
write(tempVarName);
|
||||
write(": ");
|
||||
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
|
||||
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
|
||||
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
write(";");
|
||||
writeLine();
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
|
@ -1025,7 +1025,7 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError;
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
|
|
|
@ -1946,6 +1946,7 @@ namespace ts {
|
|||
UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type
|
||||
InTypeAlias = 0x00000200, // Writing type in type alias declaration
|
||||
UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
//// [tests/cases/compiler/declarationEmitInferedTypeAlias1.ts] ////
|
||||
|
||||
//// [0.ts]
|
||||
|
||||
{
|
||||
type Data = string | boolean;
|
||||
let obj: Data = true;
|
||||
}
|
||||
export { }
|
||||
|
||||
//// [1.ts]
|
||||
let v = "str" || true;
|
||||
export { v }
|
||||
|
||||
//// [0.js]
|
||||
"use strict";
|
||||
{
|
||||
var obj = true;
|
||||
}
|
||||
//// [1.js]
|
||||
"use strict";
|
||||
var v = "str" || true;
|
||||
exports.v = v;
|
||||
|
||||
|
||||
//// [0.d.ts]
|
||||
export { };
|
||||
//// [1.d.ts]
|
||||
declare let v: string | boolean;
|
||||
export { v };
|
|
@ -0,0 +1,19 @@
|
|||
=== tests/cases/compiler/0.ts ===
|
||||
|
||||
{
|
||||
type Data = string | boolean;
|
||||
>Data : Symbol(Data, Decl(0.ts, 1, 1))
|
||||
|
||||
let obj: Data = true;
|
||||
>obj : Symbol(obj, Decl(0.ts, 3, 7))
|
||||
>Data : Symbol(Data, Decl(0.ts, 1, 1))
|
||||
}
|
||||
export { }
|
||||
|
||||
=== tests/cases/compiler/1.ts ===
|
||||
let v = "str" || true;
|
||||
>v : Symbol(v, Decl(1.ts, 0, 3))
|
||||
|
||||
export { v }
|
||||
>v : Symbol(v, Decl(1.ts, 1, 8))
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
=== tests/cases/compiler/0.ts ===
|
||||
|
||||
{
|
||||
type Data = string | boolean;
|
||||
>Data : Data
|
||||
|
||||
let obj: Data = true;
|
||||
>obj : Data
|
||||
>Data : Data
|
||||
>true : true
|
||||
}
|
||||
export { }
|
||||
|
||||
=== tests/cases/compiler/1.ts ===
|
||||
let v = "str" || true;
|
||||
>v : Data
|
||||
>"str" || true : Data
|
||||
>"str" : string
|
||||
>true : boolean
|
||||
|
||||
export { v }
|
||||
>v : Data
|
||||
|
|
@ -38,5 +38,5 @@ function rawr(dino) {
|
|||
//// [stringLiteralTypesAndTuples01.d.ts]
|
||||
declare let hello: string, brave: string, newish: string, world: string;
|
||||
declare type RexOrRaptor = "t-rex" | "raptor";
|
||||
declare let im: "I'm", a: "a", dinosaur: RexOrRaptor;
|
||||
declare let im: "I'm", a: "a", dinosaur: "t-rex" | "raptor";
|
||||
declare function rawr(dino: RexOrRaptor): string;
|
||||
|
|
|
@ -109,6 +109,6 @@ declare const boolean: "boolean";
|
|||
declare const stringOrNumber: "string" | "number";
|
||||
declare const stringOrBoolean: "string" | "boolean";
|
||||
declare const booleanOrNumber: "number" | "boolean";
|
||||
declare const stringOrBooleanOrNumber: PrimitiveName;
|
||||
declare const stringOrBooleanOrNumber: "string" | "number" | "boolean";
|
||||
declare namespace Consts2 {
|
||||
}
|
||||
|
|
13
tests/cases/compiler/declarationEmitInferedTypeAlias1.ts
Normal file
13
tests/cases/compiler/declarationEmitInferedTypeAlias1.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
// @declaration: true
|
||||
// @skipDefaultLibCheck: true
|
||||
|
||||
// @Filename: 0.ts
|
||||
{
|
||||
type Data = string | boolean;
|
||||
let obj: Data = true;
|
||||
}
|
||||
export { }
|
||||
|
||||
// @Filename: 1.ts
|
||||
let v = "str" || true;
|
||||
export { v }
|
Loading…
Reference in a new issue