Merge branch 'master' into improve-arity-error
This commit is contained in:
commit
f1a1b7fca9
105 changed files with 4931 additions and 1173 deletions
10
Gulpfile.ts
10
Gulpfile.ts
|
@ -935,7 +935,7 @@ gulp.task(loggedIOJsPath, /*help*/ false, [], (done) => {
|
||||||
const temp = path.join(builtLocalDirectory, "temp");
|
const temp = path.join(builtLocalDirectory, "temp");
|
||||||
mkdirP(temp, (err) => {
|
mkdirP(temp, (err) => {
|
||||||
if (err) { console.error(err); done(err); process.exit(1); }
|
if (err) { console.error(err); done(err); process.exit(1); }
|
||||||
exec(host, [LKGCompiler, "--types --outdir", temp, loggedIOpath], () => {
|
exec(host, [LKGCompiler, "--types", "--target es5", "--lib es5", "--outdir", temp, loggedIOpath], () => {
|
||||||
fs.renameSync(path.join(temp, "/harness/loggedIO.js"), loggedIOJsPath);
|
fs.renameSync(path.join(temp, "/harness/loggedIO.js"), loggedIOJsPath);
|
||||||
del(temp).then(() => done(), done);
|
del(temp).then(() => done(), done);
|
||||||
}, done);
|
}, done);
|
||||||
|
@ -946,7 +946,13 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts");
|
||||||
const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js");
|
const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js");
|
||||||
gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
|
gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
|
||||||
const settings: tsc.Settings = getCompilerSettings({
|
const settings: tsc.Settings = getCompilerSettings({
|
||||||
outFile: instrumenterJsPath
|
outFile: instrumenterJsPath,
|
||||||
|
target: "es5",
|
||||||
|
lib: [
|
||||||
|
"es6",
|
||||||
|
"dom",
|
||||||
|
"scripthost"
|
||||||
|
]
|
||||||
}, /*useBuiltCompiler*/ true);
|
}, /*useBuiltCompiler*/ true);
|
||||||
return gulp.src(instrumenterPath)
|
return gulp.src(instrumenterPath)
|
||||||
.pipe(newer(instrumenterJsPath))
|
.pipe(newer(instrumenterJsPath))
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace ts {
|
||||||
inStrictMode = bindInStrictMode(file, opts);
|
inStrictMode = bindInStrictMode(file, opts);
|
||||||
classifiableNames = createMap<string>();
|
classifiableNames = createMap<string>();
|
||||||
symbolCount = 0;
|
symbolCount = 0;
|
||||||
skipTransformFlagAggregation = isDeclarationFile(file);
|
skipTransformFlagAggregation = file.isDeclarationFile;
|
||||||
|
|
||||||
Symbol = objectAllocator.getSymbolConstructor();
|
Symbol = objectAllocator.getSymbolConstructor();
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace ts {
|
||||||
return bindSourceFile;
|
return bindSourceFile;
|
||||||
|
|
||||||
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
|
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
|
||||||
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) {
|
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !file.isDeclarationFile) {
|
||||||
// bind in strict mode source files with alwaysStrict option
|
// bind in strict mode source files with alwaysStrict option
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2527,7 +2527,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindFunctionDeclaration(node: FunctionDeclaration) {
|
function bindFunctionDeclaration(node: FunctionDeclaration) {
|
||||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
|
||||||
if (isAsyncFunction(node)) {
|
if (isAsyncFunction(node)) {
|
||||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||||
}
|
}
|
||||||
|
@ -2544,7 +2544,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindFunctionExpression(node: FunctionExpression) {
|
function bindFunctionExpression(node: FunctionExpression) {
|
||||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
|
||||||
if (isAsyncFunction(node)) {
|
if (isAsyncFunction(node)) {
|
||||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||||
}
|
}
|
||||||
|
@ -2558,7 +2558,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||||
if (!isDeclarationFile(file) && !isInAmbientContext(node)) {
|
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
|
||||||
if (isAsyncFunction(node)) {
|
if (isAsyncFunction(node)) {
|
||||||
emitFlags |= NodeFlags.HasAsyncFunctions;
|
emitFlags |= NodeFlags.HasAsyncFunctions;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -230,6 +230,8 @@ namespace ts {
|
||||||
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
|
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
|
||||||
* At that point findAncestor returns undefined.
|
* At that point findAncestor returns undefined.
|
||||||
*/
|
*/
|
||||||
|
export function findAncestor<T extends Node>(node: Node, callback: (element: Node) => element is T): T | undefined;
|
||||||
|
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node | undefined;
|
||||||
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node {
|
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node {
|
||||||
while (node) {
|
while (node) {
|
||||||
const result = callback(node);
|
const result = callback(node);
|
||||||
|
|
|
@ -984,7 +984,7 @@ namespace ts {
|
||||||
const enumMemberValue = resolver.getConstantValue(node);
|
const enumMemberValue = resolver.getConstantValue(node);
|
||||||
if (enumMemberValue !== undefined) {
|
if (enumMemberValue !== undefined) {
|
||||||
write(" = ");
|
write(" = ");
|
||||||
write(enumMemberValue.toString());
|
write(getTextOfConstantValue(enumMemberValue));
|
||||||
}
|
}
|
||||||
write(",");
|
write(",");
|
||||||
writeLine();
|
writeLine();
|
||||||
|
@ -1840,7 +1840,7 @@ namespace ts {
|
||||||
function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean, emitOnlyDtsFiles: boolean): boolean {
|
function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean, emitOnlyDtsFiles: boolean): boolean {
|
||||||
let declFileName: string;
|
let declFileName: string;
|
||||||
let addedBundledEmitReference = false;
|
let addedBundledEmitReference = false;
|
||||||
if (isDeclarationFile(referencedFile)) {
|
if (referencedFile.isDeclarationFile) {
|
||||||
// Declaration file, use declaration file name
|
// Declaration file, use declaration file name
|
||||||
declFileName = referencedFile.fileName;
|
declFileName = referencedFile.fileName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1855,25 +1855,29 @@
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2552
|
"code": 2552
|
||||||
},
|
},
|
||||||
"Expected {0} arguments, but got {1}.": {
|
"Computed values are not permitted in an enum with string valued members.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2553
|
"code": 2553
|
||||||
},
|
},
|
||||||
"Expected at least {0} arguments, but got {1}.": {
|
"Expected {0} arguments, but got {1}.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2554
|
"code": 2554
|
||||||
},
|
},
|
||||||
|
"Expected at least {0} arguments, but got {1}.": {
|
||||||
|
"category": "Error",
|
||||||
|
"code": 2555
|
||||||
|
},
|
||||||
"Expected {0} arguments, but got a minimum of {1}.": {
|
"Expected {0} arguments, but got a minimum of {1}.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2555
|
"code": 2555
|
||||||
},
|
},
|
||||||
"Expected at least {0} arguments, but got a minimum of {1}.": {
|
"Expected at least {0} arguments, but got a minimum of {1}.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2556
|
"code": 2557
|
||||||
},
|
},
|
||||||
"Expected {0} type arguments, but got {1}.": {
|
"Expected {0} type arguments, but got {1}.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
"code": 2557
|
"code": 2558
|
||||||
},
|
},
|
||||||
"JSX element attributes type '{0}' may not be a union type.": {
|
"JSX element attributes type '{0}' may not be a union type.": {
|
||||||
"category": "Error",
|
"category": "Error",
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace ts {
|
||||||
for (let i = 0; i < numNodes; i++) {
|
for (let i = 0; i < numNodes; i++) {
|
||||||
const currentNode = bundle ? bundle.sourceFiles[i] : node;
|
const currentNode = bundle ? bundle.sourceFiles[i] : node;
|
||||||
const sourceFile = isSourceFile(currentNode) ? currentNode : currentSourceFile;
|
const sourceFile = isSourceFile(currentNode) ? currentNode : currentSourceFile;
|
||||||
const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined);
|
const shouldSkip = compilerOptions.noEmitHelpers || getExternalHelpersModuleName(sourceFile) !== undefined;
|
||||||
const shouldBundle = isSourceFile(currentNode) && !isOwnFileEmit;
|
const shouldBundle = isSourceFile(currentNode) && !isOwnFileEmit;
|
||||||
const helpers = getEmitHelpers(currentNode);
|
const helpers = getEmitHelpers(currentNode);
|
||||||
if (helpers) {
|
if (helpers) {
|
||||||
|
@ -212,7 +212,7 @@ namespace ts {
|
||||||
emitLeadingCommentsOfPosition,
|
emitLeadingCommentsOfPosition,
|
||||||
} = comments;
|
} = comments;
|
||||||
|
|
||||||
let currentSourceFile: SourceFile;
|
let currentSourceFile: SourceFile | undefined;
|
||||||
let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes.
|
let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes.
|
||||||
let autoGeneratedIdToGeneratedName: string[]; // Map of generated names for temp and loop variables.
|
let autoGeneratedIdToGeneratedName: string[]; // Map of generated names for temp and loop variables.
|
||||||
let generatedNames: Map<string>; // Set of names generated by the NameGenerator.
|
let generatedNames: Map<string>; // Set of names generated by the NameGenerator.
|
||||||
|
@ -264,7 +264,12 @@ namespace ts {
|
||||||
return endPrint();
|
return endPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter) {
|
/**
|
||||||
|
* If `sourceFile` is `undefined`, `node` must be a synthesized `TypeNode`.
|
||||||
|
*/
|
||||||
|
function writeNode(hint: EmitHint, node: TypeNode, sourceFile: undefined, output: EmitTextWriter): void;
|
||||||
|
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter): void;
|
||||||
|
function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, output: EmitTextWriter) {
|
||||||
const previousWriter = writer;
|
const previousWriter = writer;
|
||||||
setWriter(output);
|
setWriter(output);
|
||||||
print(hint, node, sourceFile);
|
print(hint, node, sourceFile);
|
||||||
|
@ -305,8 +310,10 @@ namespace ts {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function print(hint: EmitHint, node: Node, sourceFile: SourceFile) {
|
function print(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined) {
|
||||||
setSourceFile(sourceFile);
|
if (sourceFile) {
|
||||||
|
setSourceFile(sourceFile);
|
||||||
|
}
|
||||||
pipelineEmitWithNotification(hint, node);
|
pipelineEmitWithNotification(hint, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,6 +788,7 @@ namespace ts {
|
||||||
|
|
||||||
function emitIdentifier(node: Identifier) {
|
function emitIdentifier(node: Identifier) {
|
||||||
write(getTextOfNode(node, /*includeTrivia*/ false));
|
write(getTextOfNode(node, /*includeTrivia*/ false));
|
||||||
|
emitTypeArguments(node, node.typeArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -815,6 +823,7 @@ namespace ts {
|
||||||
function emitTypeParameter(node: TypeParameterDeclaration) {
|
function emitTypeParameter(node: TypeParameterDeclaration) {
|
||||||
emit(node.name);
|
emit(node.name);
|
||||||
emitWithPrefix(" extends ", node.constraint);
|
emitWithPrefix(" extends ", node.constraint);
|
||||||
|
emitWithPrefix(" = ", node.default);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitParameter(node: ParameterDeclaration) {
|
function emitParameter(node: ParameterDeclaration) {
|
||||||
|
@ -955,7 +964,10 @@ namespace ts {
|
||||||
|
|
||||||
function emitTypeLiteral(node: TypeLiteralNode) {
|
function emitTypeLiteral(node: TypeLiteralNode) {
|
||||||
write("{");
|
write("{");
|
||||||
emitList(node, node.members, ListFormat.TypeLiteralMembers);
|
// If the literal is empty, do not add spaces between braces.
|
||||||
|
if (node.members.length > 0) {
|
||||||
|
emitList(node, node.members, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers);
|
||||||
|
}
|
||||||
write("}");
|
write("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,9 +1014,15 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitMappedType(node: MappedTypeNode) {
|
function emitMappedType(node: MappedTypeNode) {
|
||||||
|
const emitFlags = getEmitFlags(node);
|
||||||
write("{");
|
write("{");
|
||||||
writeLine();
|
if (emitFlags & EmitFlags.SingleLine) {
|
||||||
increaseIndent();
|
write(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writeLine();
|
||||||
|
increaseIndent();
|
||||||
|
}
|
||||||
writeIfPresent(node.readonlyToken, "readonly ");
|
writeIfPresent(node.readonlyToken, "readonly ");
|
||||||
write("[");
|
write("[");
|
||||||
emit(node.typeParameter.name);
|
emit(node.typeParameter.name);
|
||||||
|
@ -1015,8 +1033,13 @@ namespace ts {
|
||||||
write(": ");
|
write(": ");
|
||||||
emit(node.type);
|
emit(node.type);
|
||||||
write(";");
|
write(";");
|
||||||
writeLine();
|
if (emitFlags & EmitFlags.SingleLine) {
|
||||||
decreaseIndent();
|
write(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writeLine();
|
||||||
|
decreaseIndent();
|
||||||
|
}
|
||||||
write("}");
|
write("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1035,7 +1058,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
write("{");
|
write("{");
|
||||||
emitList(node, elements, ListFormat.ObjectBindingPatternElements);
|
emitList(node, elements, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.ObjectBindingPatternElements : ListFormat.ObjectBindingPatternElementsWithSpaceBetweenBraces);
|
||||||
write("}");
|
write("}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1131,7 +1154,7 @@ namespace ts {
|
||||||
// check if constant enum value is integer
|
// check if constant enum value is integer
|
||||||
const constantValue = getConstantValue(expression);
|
const constantValue = getConstantValue(expression);
|
||||||
// isFinite handles cases when constantValue is undefined
|
// isFinite handles cases when constantValue is undefined
|
||||||
return isFinite(constantValue)
|
return typeof constantValue === "number" && isFinite(constantValue)
|
||||||
&& Math.floor(constantValue) === constantValue
|
&& Math.floor(constantValue) === constantValue
|
||||||
&& printerOptions.removeComments;
|
&& printerOptions.removeComments;
|
||||||
}
|
}
|
||||||
|
@ -2637,7 +2660,9 @@ namespace ts {
|
||||||
if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
if (node.kind === SyntaxKind.StringLiteral && (<StringLiteral>node).textSourceNode) {
|
||||||
const textSourceNode = (<StringLiteral>node).textSourceNode;
|
const textSourceNode = (<StringLiteral>node).textSourceNode;
|
||||||
if (isIdentifier(textSourceNode)) {
|
if (isIdentifier(textSourceNode)) {
|
||||||
return "\"" + escapeNonAsciiCharacters(escapeString(getTextOfNode(textSourceNode))) + "\"";
|
return getEmitFlags(node) & EmitFlags.NoAsciiEscaping ?
|
||||||
|
`"${escapeString(getTextOfNode(textSourceNode))}"` :
|
||||||
|
`"${escapeNonAsciiString(getTextOfNode(textSourceNode))}"`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getLiteralTextOfNode(textSourceNode);
|
return getLiteralTextOfNode(textSourceNode);
|
||||||
|
@ -2950,11 +2975,14 @@ namespace ts {
|
||||||
// Precomputed Formats
|
// Precomputed Formats
|
||||||
Modifiers = SingleLine | SpaceBetweenSiblings,
|
Modifiers = SingleLine | SpaceBetweenSiblings,
|
||||||
HeritageClauses = SingleLine | SpaceBetweenSiblings,
|
HeritageClauses = SingleLine | SpaceBetweenSiblings,
|
||||||
TypeLiteralMembers = MultiLine | Indented,
|
SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings | Indented,
|
||||||
|
MultiLineTypeLiteralMembers = MultiLine | Indented,
|
||||||
|
|
||||||
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented,
|
TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented,
|
||||||
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
|
UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine,
|
||||||
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
|
IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine,
|
||||||
ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings,
|
ObjectBindingPatternElements = SingleLine | CommaDelimited | SpaceBetweenSiblings,
|
||||||
|
ObjectBindingPatternElementsWithSpaceBetweenBraces = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings,
|
||||||
ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings,
|
ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings,
|
||||||
ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces,
|
ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces,
|
||||||
ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets,
|
ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets,
|
||||||
|
|
|
@ -107,15 +107,27 @@ namespace ts {
|
||||||
|
|
||||||
// Identifiers
|
// Identifiers
|
||||||
|
|
||||||
export function createIdentifier(text: string): Identifier {
|
export function createIdentifier(text: string): Identifier;
|
||||||
|
/* @internal */
|
||||||
|
export function createIdentifier(text: string, typeArguments: TypeNode[]): Identifier;
|
||||||
|
export function createIdentifier(text: string, typeArguments?: TypeNode[]): Identifier {
|
||||||
const node = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
const node = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||||
node.text = escapeIdentifier(text);
|
node.text = escapeIdentifier(text);
|
||||||
node.originalKeywordKind = text ? stringToToken(text) : SyntaxKind.Unknown;
|
node.originalKeywordKind = text ? stringToToken(text) : SyntaxKind.Unknown;
|
||||||
node.autoGenerateKind = GeneratedIdentifierKind.None;
|
node.autoGenerateKind = GeneratedIdentifierKind.None;
|
||||||
node.autoGenerateId = 0;
|
node.autoGenerateId = 0;
|
||||||
|
if (typeArguments) {
|
||||||
|
node.typeArguments = createNodeArray(typeArguments);
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode> | undefined): Identifier {
|
||||||
|
return node.typeArguments !== typeArguments
|
||||||
|
? updateNode(createIdentifier(node.text, typeArguments), node)
|
||||||
|
: node;
|
||||||
|
}
|
||||||
|
|
||||||
let nextAutoGenerateId = 0;
|
let nextAutoGenerateId = 0;
|
||||||
|
|
||||||
/** Create a unique temporary variable. */
|
/** Create a unique temporary variable. */
|
||||||
|
@ -271,8 +283,9 @@ namespace ts {
|
||||||
|
|
||||||
// Type Elements
|
// Type Elements
|
||||||
|
|
||||||
export function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature {
|
export function createPropertySignature(modifiers: Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature {
|
||||||
const node = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature;
|
const node = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature;
|
||||||
|
node.modifiers = asNodeArray(modifiers);
|
||||||
node.name = asName(name);
|
node.name = asName(name);
|
||||||
node.questionToken = questionToken;
|
node.questionToken = questionToken;
|
||||||
node.type = type;
|
node.type = type;
|
||||||
|
@ -280,12 +293,13 @@ namespace ts {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) {
|
export function updatePropertySignature(node: PropertySignature, modifiers: Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) {
|
||||||
return node.name !== name
|
return node.modifiers !== modifiers
|
||||||
|
|| node.name !== name
|
||||||
|| node.questionToken !== questionToken
|
|| node.questionToken !== questionToken
|
||||||
|| node.type !== type
|
|| node.type !== type
|
||||||
|| node.initializer !== initializer
|
|| node.initializer !== initializer
|
||||||
? updateNode(createPropertySignature(name, questionToken, type, initializer), node)
|
? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node)
|
||||||
: node;
|
: node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +506,7 @@ namespace ts {
|
||||||
export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) {
|
export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) {
|
||||||
const node = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode;
|
const node = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode;
|
||||||
node.typeName = asName(typeName);
|
node.typeName = asName(typeName);
|
||||||
node.typeArguments = asNodeArray(typeArguments);
|
node.typeArguments = typeArguments && parenthesizeTypeParameters(typeArguments);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +559,7 @@ namespace ts {
|
||||||
|
|
||||||
export function createArrayTypeNode(elementType: TypeNode) {
|
export function createArrayTypeNode(elementType: TypeNode) {
|
||||||
const node = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode;
|
const node = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode;
|
||||||
node.elementType = elementType;
|
node.elementType = parenthesizeElementTypeMember(elementType);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +599,7 @@ namespace ts {
|
||||||
|
|
||||||
export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) {
|
export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) {
|
||||||
const node = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode;
|
const node = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode;
|
||||||
node.types = createNodeArray(types);
|
node.types = parenthesizeElementTypeMembers(types);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +628,7 @@ namespace ts {
|
||||||
export function createTypeOperatorNode(type: TypeNode) {
|
export function createTypeOperatorNode(type: TypeNode) {
|
||||||
const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode;
|
const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode;
|
||||||
node.operator = SyntaxKind.KeyOfKeyword;
|
node.operator = SyntaxKind.KeyOfKeyword;
|
||||||
node.type = type;
|
node.type = parenthesizeElementTypeMember(type);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +638,7 @@ namespace ts {
|
||||||
|
|
||||||
export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) {
|
export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) {
|
||||||
const node = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode;
|
const node = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode;
|
||||||
node.objectType = objectType;
|
node.objectType = parenthesizeElementTypeMember(objectType);
|
||||||
node.indexType = indexType;
|
node.indexType = indexType;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -2357,7 +2371,7 @@ namespace ts {
|
||||||
/**
|
/**
|
||||||
* Sets the constant value to emit for an expression.
|
* Sets the constant value to emit for an expression.
|
||||||
*/
|
*/
|
||||||
export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number) {
|
export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number) {
|
||||||
const emitNode = getOrCreateEmitNode(node);
|
const emitNode = getOrCreateEmitNode(node);
|
||||||
emitNode.constantValue = value;
|
emitNode.constantValue = value;
|
||||||
return node;
|
return node;
|
||||||
|
@ -2489,6 +2503,25 @@ namespace ts {
|
||||||
|
|
||||||
/* @internal */
|
/* @internal */
|
||||||
namespace ts {
|
namespace ts {
|
||||||
|
export const nullTransformationContext: TransformationContext = {
|
||||||
|
enableEmitNotification: noop,
|
||||||
|
enableSubstitution: noop,
|
||||||
|
endLexicalEnvironment: () => undefined,
|
||||||
|
getCompilerOptions: notImplemented,
|
||||||
|
getEmitHost: notImplemented,
|
||||||
|
getEmitResolver: notImplemented,
|
||||||
|
hoistFunctionDeclaration: noop,
|
||||||
|
hoistVariableDeclaration: noop,
|
||||||
|
isEmitNotificationEnabled: notImplemented,
|
||||||
|
isSubstitutionEnabled: notImplemented,
|
||||||
|
onEmitNode: noop,
|
||||||
|
onSubstituteNode: notImplemented,
|
||||||
|
readEmitHelpers: notImplemented,
|
||||||
|
requestEmitHelper: noop,
|
||||||
|
resumeLexicalEnvironment: noop,
|
||||||
|
startLexicalEnvironment: noop,
|
||||||
|
suspendLexicalEnvironment: noop
|
||||||
|
};
|
||||||
|
|
||||||
// Compound nodes
|
// Compound nodes
|
||||||
|
|
||||||
|
@ -3289,16 +3322,6 @@ namespace ts {
|
||||||
return statements;
|
return statements;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parenthesizeConditionalHead(condition: Expression) {
|
|
||||||
const conditionalPrecedence = getOperatorPrecedence(SyntaxKind.ConditionalExpression, SyntaxKind.QuestionToken);
|
|
||||||
const emittedCondition = skipPartiallyEmittedExpressions(condition);
|
|
||||||
const conditionPrecedence = getExpressionPrecedence(emittedCondition);
|
|
||||||
if (compareValues(conditionPrecedence, conditionalPrecedence) === Comparison.LessThan) {
|
|
||||||
return createParen(condition);
|
|
||||||
}
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended
|
* Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended
|
||||||
* order of operations.
|
* order of operations.
|
||||||
|
@ -3600,6 +3623,35 @@ namespace ts {
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parenthesizeElementTypeMember(member: TypeNode) {
|
||||||
|
switch (member.kind) {
|
||||||
|
case SyntaxKind.UnionType:
|
||||||
|
case SyntaxKind.IntersectionType:
|
||||||
|
case SyntaxKind.FunctionType:
|
||||||
|
case SyntaxKind.ConstructorType:
|
||||||
|
return createParenthesizedType(member);
|
||||||
|
}
|
||||||
|
return member;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parenthesizeElementTypeMembers(members: TypeNode[]) {
|
||||||
|
return createNodeArray(sameMap(members, parenthesizeElementTypeMember));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parenthesizeTypeParameters(typeParameters: TypeNode[]) {
|
||||||
|
if (some(typeParameters)) {
|
||||||
|
const nodeArray = createNodeArray() as NodeArray<TypeNode>;
|
||||||
|
for (let i = 0; i < typeParameters.length; ++i) {
|
||||||
|
const entry = typeParameters[i];
|
||||||
|
nodeArray.push(i === 0 && isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ?
|
||||||
|
createParenthesizedType(entry) :
|
||||||
|
entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodeArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a series of not-emitted expressions with a new inner expression.
|
* Clones a series of not-emitted expressions with a new inner expression.
|
||||||
*
|
*
|
||||||
|
@ -3806,7 +3858,7 @@ namespace ts {
|
||||||
if (file.moduleName) {
|
if (file.moduleName) {
|
||||||
return createLiteral(file.moduleName);
|
return createLiteral(file.moduleName);
|
||||||
}
|
}
|
||||||
if (!isDeclarationFile(file) && (options.out || options.outFile)) {
|
if (!file.isDeclarationFile && (options.out || options.outFile)) {
|
||||||
return createLiteral(getExternalModuleNameFromPath(host, file.fileName));
|
return createLiteral(getExternalModuleNameFromPath(host, file.fileName));
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
@ -23,19 +23,19 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
|
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T | undefined {
|
||||||
if (node) {
|
if (node) {
|
||||||
return cbNode(node);
|
return cbNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
|
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]): T | undefined {
|
||||||
if (nodes) {
|
if (nodes) {
|
||||||
return cbNodes(nodes);
|
return cbNodes(nodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
|
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]): T | undefined {
|
||||||
if (nodes) {
|
if (nodes) {
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
const result = cbNode(node);
|
const result = cbNode(node);
|
||||||
|
@ -50,7 +50,7 @@ namespace ts {
|
||||||
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
||||||
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
||||||
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
|
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
|
||||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
|
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||||
return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOptionsDiagnostics(): Diagnostic[] {
|
function getOptionsDiagnostics(): Diagnostic[] {
|
||||||
|
@ -1348,7 +1348,6 @@ namespace ts {
|
||||||
|
|
||||||
const isJavaScriptFile = isSourceFileJavaScript(file);
|
const isJavaScriptFile = isSourceFileJavaScript(file);
|
||||||
const isExternalModuleFile = isExternalModule(file);
|
const isExternalModuleFile = isExternalModule(file);
|
||||||
const isDtsFile = isDeclarationFile(file);
|
|
||||||
|
|
||||||
let imports: LiteralExpression[];
|
let imports: LiteralExpression[];
|
||||||
let moduleAugmentations: LiteralExpression[];
|
let moduleAugmentations: LiteralExpression[];
|
||||||
|
@ -1401,7 +1400,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SyntaxKind.ModuleDeclaration:
|
case SyntaxKind.ModuleDeclaration:
|
||||||
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || isDeclarationFile(file))) {
|
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) {
|
||||||
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
|
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
|
||||||
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
||||||
// This will happen in two cases:
|
// This will happen in two cases:
|
||||||
|
@ -1412,7 +1411,7 @@ namespace ts {
|
||||||
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
|
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
|
||||||
}
|
}
|
||||||
else if (!inAmbientModule) {
|
else if (!inAmbientModule) {
|
||||||
if (isDtsFile) {
|
if (file.isDeclarationFile) {
|
||||||
// for global .d.ts files record name of ambient module
|
// for global .d.ts files record name of ambient module
|
||||||
(ambientModules || (ambientModules = [])).push(moduleName.text);
|
(ambientModules || (ambientModules = [])).push(moduleName.text);
|
||||||
}
|
}
|
||||||
|
@ -1730,7 +1729,7 @@ namespace ts {
|
||||||
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
|
||||||
|
|
||||||
for (const sourceFile of sourceFiles) {
|
for (const sourceFile of sourceFiles) {
|
||||||
if (!isDeclarationFile(sourceFile)) {
|
if (!sourceFile.isDeclarationFile) {
|
||||||
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||||
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
||||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||||
|
@ -1843,13 +1842,13 @@ namespace ts {
|
||||||
const languageVersion = options.target || ScriptTarget.ES3;
|
const languageVersion = options.target || ScriptTarget.ES3;
|
||||||
const outFile = options.outFile || options.out;
|
const outFile = options.outFile || options.out;
|
||||||
|
|
||||||
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
|
||||||
if (options.isolatedModules) {
|
if (options.isolatedModules) {
|
||||||
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) {
|
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) {
|
||||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !f.isDeclarationFile ? f : undefined);
|
||||||
if (firstNonExternalModuleSourceFile) {
|
if (firstNonExternalModuleSourceFile) {
|
||||||
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||||
|
|
|
@ -712,11 +712,11 @@ namespace ts {
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) {
|
export function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined {
|
||||||
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state);
|
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) {
|
export function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined {
|
||||||
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state);
|
return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,10 +746,11 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Optionally, get the shebang */
|
/** Optionally, get the shebang */
|
||||||
export function getShebang(text: string): string {
|
export function getShebang(text: string): string | undefined {
|
||||||
return shebangTriviaRegex.test(text)
|
const match = shebangTriviaRegex.exec(text);
|
||||||
? shebangTriviaRegex.exec(text)[0]
|
if (match) {
|
||||||
: undefined;
|
return match[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean {
|
export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean {
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace ts {
|
||||||
};
|
};
|
||||||
|
|
||||||
function transformRoot(node: T) {
|
function transformRoot(node: T) {
|
||||||
return node && (!isSourceFile(node) || !isDeclarationFile(node)) ? transformation(node) : node;
|
return node && (!isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -295,7 +295,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,8 +929,8 @@ namespace ts {
|
||||||
text: `
|
text: `
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
`
|
`
|
||||||
};
|
};
|
||||||
|
|
|
@ -293,8 +293,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)
|
if (node.isDeclarationFile || (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
|
||||||
|| (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace ts {
|
||||||
* @param node A SourceFile node.
|
* @param node A SourceFile node.
|
||||||
*/
|
*/
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ts {
|
||||||
return transformSourceFile;
|
return transformSourceFile;
|
||||||
|
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace ts {
|
||||||
* @param node The SourceFile node.
|
* @param node The SourceFile node.
|
||||||
*/
|
*/
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
|
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,7 @@ namespace ts {
|
||||||
* @param node The SourceFile node.
|
* @param node The SourceFile node.
|
||||||
*/
|
*/
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)
|
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
|
||||||
|| !(isExternalModule(node)
|
|
||||||
|| compilerOptions.isolatedModules)) {
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace ts {
|
||||||
* @param node A SourceFile node.
|
* @param node A SourceFile node.
|
||||||
*/
|
*/
|
||||||
function transformSourceFile(node: SourceFile) {
|
function transformSourceFile(node: SourceFile) {
|
||||||
if (isDeclarationFile(node)) {
|
if (node.isDeclarationFile) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2494,22 +2494,27 @@ namespace ts {
|
||||||
// we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes
|
// we pass false as 'generateNameForComputedPropertyName' for a backward compatibility purposes
|
||||||
// old emitter always generate 'expression' part of the name as-is.
|
// old emitter always generate 'expression' part of the name as-is.
|
||||||
const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
|
const name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false);
|
||||||
|
const valueExpression = transformEnumMemberDeclarationValue(member);
|
||||||
|
const innerAssignment = createAssignment(
|
||||||
|
createElementAccess(
|
||||||
|
currentNamespaceContainerName,
|
||||||
|
name
|
||||||
|
),
|
||||||
|
valueExpression
|
||||||
|
);
|
||||||
|
const outerAssignment = valueExpression.kind === SyntaxKind.StringLiteral ?
|
||||||
|
innerAssignment :
|
||||||
|
createAssignment(
|
||||||
|
createElementAccess(
|
||||||
|
currentNamespaceContainerName,
|
||||||
|
innerAssignment
|
||||||
|
),
|
||||||
|
name
|
||||||
|
);
|
||||||
return setTextRange(
|
return setTextRange(
|
||||||
createStatement(
|
createStatement(
|
||||||
setTextRange(
|
setTextRange(
|
||||||
createAssignment(
|
outerAssignment,
|
||||||
createElementAccess(
|
|
||||||
currentNamespaceContainerName,
|
|
||||||
createAssignment(
|
|
||||||
createElementAccess(
|
|
||||||
currentNamespaceContainerName,
|
|
||||||
name
|
|
||||||
),
|
|
||||||
transformEnumMemberDeclarationValue(member)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
name
|
|
||||||
),
|
|
||||||
member
|
member
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -3349,7 +3354,7 @@ namespace ts {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryGetConstEnumValue(node: Node): number {
|
function tryGetConstEnumValue(node: Node): string | number {
|
||||||
if (compilerOptions.isolatedModules) {
|
if (compilerOptions.isolatedModules) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,10 +577,11 @@ namespace ts {
|
||||||
* If the identifier begins with two underscores, this will begin with three.
|
* If the identifier begins with two underscores, this will begin with three.
|
||||||
*/
|
*/
|
||||||
text: string;
|
text: string;
|
||||||
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
|
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
|
||||||
/*@internal*/ autoGenerateKind?: GeneratedIdentifierKind; // Specifies whether to auto-generate the text for an identifier.
|
/*@internal*/ autoGenerateKind?: GeneratedIdentifierKind; // Specifies whether to auto-generate the text for an identifier.
|
||||||
/*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name.
|
/*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name.
|
||||||
isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace
|
isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace
|
||||||
|
/*@internal*/ typeArguments?: NodeArray<TypeNode>; // Only defined on synthesized nodes. Though not syntactically valid, used in emitting diagnostics.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transient identifier node (marked by id === -1)
|
// Transient identifier node (marked by id === -1)
|
||||||
|
@ -2527,11 +2528,11 @@ namespace ts {
|
||||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration;
|
||||||
|
|
||||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||||
getSymbolAtLocation(node: Node): Symbol;
|
getSymbolAtLocation(node: Node): Symbol | undefined;
|
||||||
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
|
||||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
|
||||||
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol;
|
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
|
||||||
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
|
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
|
||||||
getTypeAtLocation(node: Node): Type;
|
getTypeAtLocation(node: Node): Type;
|
||||||
getTypeFromTypeNode(node: TypeNode): Type;
|
getTypeFromTypeNode(node: TypeNode): Type;
|
||||||
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
|
||||||
|
@ -2542,15 +2543,15 @@ namespace ts {
|
||||||
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
getAugmentedPropertiesOfType(type: Type): Symbol[];
|
||||||
getRootSymbols(symbol: Symbol): Symbol[];
|
getRootSymbols(symbol: Symbol): Symbol[];
|
||||||
getContextualType(node: Expression): Type | undefined;
|
getContextualType(node: Expression): Type | undefined;
|
||||||
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature;
|
getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined;
|
||||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined;
|
||||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||||
isUnknownSymbol(symbol: Symbol): boolean;
|
isUnknownSymbol(symbol: Symbol): boolean;
|
||||||
/* @internal */ getMergedSymbol(symbol: Symbol): Symbol;
|
/* @internal */ getMergedSymbol(symbol: Symbol): Symbol;
|
||||||
|
|
||||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
|
||||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||||
/** Follow all aliases to get the original symbol. */
|
/** Follow all aliases to get the original symbol. */
|
||||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||||
|
@ -2560,7 +2561,7 @@ namespace ts {
|
||||||
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
|
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
|
||||||
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
|
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
|
||||||
|
|
||||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type;
|
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||||
getJsxIntrinsicTagNames(): Symbol[];
|
getJsxIntrinsicTagNames(): Symbol[];
|
||||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||||
getAmbientModules(): Symbol[];
|
getAmbientModules(): Symbol[];
|
||||||
|
@ -2568,10 +2569,10 @@ namespace ts {
|
||||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||||
getApparentType(type: Type): Type;
|
getApparentType(type: Type): Type;
|
||||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string;
|
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||||
/* @internal */ getBaseConstraintOfType(type: Type): Type;
|
/* @internal */ getBaseConstraintOfType(type: Type): Type | undefined;
|
||||||
|
|
||||||
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
|
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined;
|
||||||
|
|
||||||
// Should not be called directly. Should only be accessed through the Program instance.
|
// Should not be called directly. Should only be accessed through the Program instance.
|
||||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||||
|
@ -2586,24 +2587,39 @@ namespace ts {
|
||||||
/**
|
/**
|
||||||
* For a union, will include a property if it's defined in *any* of the member types.
|
* For a union, will include a property if it's defined in *any* of the member types.
|
||||||
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
||||||
|
* Does not include properties of primitive types.
|
||||||
*/
|
*/
|
||||||
/* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[];
|
/* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NodeBuilderFlags {
|
export enum NodeBuilderFlags {
|
||||||
None = 0,
|
None = 0,
|
||||||
allowThisInObjectLiteral = 1 << 0,
|
// Options
|
||||||
allowQualifedNameInPlaceOfIdentifier = 1 << 1,
|
NoTruncation = 1 << 0, // Don't truncate result
|
||||||
allowTypeParameterInQualifiedName = 1 << 2,
|
WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[]
|
||||||
allowAnonymousIdentifier = 1 << 3,
|
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
||||||
allowEmptyUnionOrIntersection = 1 << 4,
|
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||||
allowEmptyTuple = 1 << 5
|
SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type.
|
||||||
|
WriteTypeParametersInQualifiedName = 1 << 9,
|
||||||
|
|
||||||
|
// Error handling
|
||||||
|
AllowThisInObjectLiteral = 1 << 10,
|
||||||
|
AllowQualifedNameInPlaceOfIdentifier = 1 << 11,
|
||||||
|
AllowAnonymousIdentifier = 1 << 13,
|
||||||
|
AllowEmptyUnionOrIntersection = 1 << 14,
|
||||||
|
AllowEmptyTuple = 1 << 15,
|
||||||
|
|
||||||
|
IgnoreErrors = AllowThisInObjectLiteral | AllowQualifedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple,
|
||||||
|
|
||||||
|
// State
|
||||||
|
InObjectTypeLiteral = 1 << 20,
|
||||||
|
InTypeAlias = 1 << 23, // Writing type in type alias declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SymbolDisplayBuilder {
|
export interface SymbolDisplayBuilder {
|
||||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||||
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void;
|
||||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||||
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void;
|
||||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||||
|
@ -2753,7 +2769,7 @@ namespace ts {
|
||||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||||
isDeclarationVisible(node: Declaration): boolean;
|
isDeclarationVisible(node: Declaration): boolean;
|
||||||
collectLinkedAliases(node: Identifier): Node[];
|
collectLinkedAliases(node: Identifier): Node[];
|
||||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined;
|
||||||
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
|
isRequiredInitializedParameter(node: ParameterDeclaration): boolean;
|
||||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||||
|
@ -2761,7 +2777,7 @@ namespace ts {
|
||||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
||||||
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number;
|
||||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||||
getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind;
|
getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind;
|
||||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||||
|
@ -2899,6 +2915,13 @@ namespace ts {
|
||||||
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
|
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
|
||||||
bindingElement?: BindingElement; // Binding element associated with property symbol
|
bindingElement?: BindingElement; // Binding element associated with property symbol
|
||||||
exportsSomeValue?: boolean; // True if module exports some value (not just types)
|
exportsSomeValue?: boolean; // True if module exports some value (not just types)
|
||||||
|
enumKind?: EnumKind; // Enum declaration classification
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @internal */
|
||||||
|
export const enum EnumKind {
|
||||||
|
Numeric, // Numeric enum (each member has a TypeFlags.Enum type)
|
||||||
|
Literal // Literal enum (each member has a TypeFlags.EnumLiteral type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @internal */
|
/* @internal */
|
||||||
|
@ -2971,7 +2994,7 @@ namespace ts {
|
||||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||||
maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate
|
maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate
|
||||||
enumMemberValue?: number; // Constant value of enum member
|
enumMemberValue?: string | number; // Constant value of enum member
|
||||||
isVisible?: boolean; // Is this node visible
|
isVisible?: boolean; // Is this node visible
|
||||||
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
||||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||||
|
@ -2991,7 +3014,7 @@ namespace ts {
|
||||||
StringLiteral = 1 << 5,
|
StringLiteral = 1 << 5,
|
||||||
NumberLiteral = 1 << 6,
|
NumberLiteral = 1 << 6,
|
||||||
BooleanLiteral = 1 << 7,
|
BooleanLiteral = 1 << 7,
|
||||||
EnumLiteral = 1 << 8,
|
EnumLiteral = 1 << 8, // Always combined with StringLiteral, NumberLiteral, or Union
|
||||||
ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6
|
ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6
|
||||||
Void = 1 << 10,
|
Void = 1 << 10,
|
||||||
Undefined = 1 << 11,
|
Undefined = 1 << 11,
|
||||||
|
@ -3017,7 +3040,7 @@ namespace ts {
|
||||||
|
|
||||||
/* @internal */
|
/* @internal */
|
||||||
Nullable = Undefined | Null,
|
Nullable = Undefined | Null,
|
||||||
Literal = StringLiteral | NumberLiteral | BooleanLiteral | EnumLiteral,
|
Literal = StringLiteral | NumberLiteral | BooleanLiteral,
|
||||||
StringOrNumberLiteral = StringLiteral | NumberLiteral,
|
StringOrNumberLiteral = StringLiteral | NumberLiteral,
|
||||||
/* @internal */
|
/* @internal */
|
||||||
DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null,
|
DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null,
|
||||||
|
@ -3025,9 +3048,9 @@ namespace ts {
|
||||||
/* @internal */
|
/* @internal */
|
||||||
Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
|
Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive,
|
||||||
/* @internal */
|
/* @internal */
|
||||||
Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal,
|
Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal,
|
||||||
StringLike = String | StringLiteral | Index,
|
StringLike = String | StringLiteral | Index,
|
||||||
NumberLike = Number | NumberLiteral | Enum | EnumLiteral,
|
NumberLike = Number | NumberLiteral | Enum,
|
||||||
BooleanLike = Boolean | BooleanLiteral,
|
BooleanLike = Boolean | BooleanLiteral,
|
||||||
EnumLike = Enum | EnumLiteral,
|
EnumLike = Enum | EnumLiteral,
|
||||||
UnionOrIntersection = Union | Intersection,
|
UnionOrIntersection = Union | Intersection,
|
||||||
|
@ -3066,19 +3089,21 @@ namespace ts {
|
||||||
// String literal types (TypeFlags.StringLiteral)
|
// String literal types (TypeFlags.StringLiteral)
|
||||||
// Numeric literal types (TypeFlags.NumberLiteral)
|
// Numeric literal types (TypeFlags.NumberLiteral)
|
||||||
export interface LiteralType extends Type {
|
export interface LiteralType extends Type {
|
||||||
text: string; // Text of literal
|
value: string | number; // Value of literal
|
||||||
freshType?: LiteralType; // Fresh version of type
|
freshType?: LiteralType; // Fresh version of type
|
||||||
regularType?: LiteralType; // Regular version of type
|
regularType?: LiteralType; // Regular version of type
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum types (TypeFlags.Enum)
|
export interface StringLiteralType extends LiteralType {
|
||||||
export interface EnumType extends Type {
|
value: string;
|
||||||
memberTypes: EnumLiteralType[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum types (TypeFlags.EnumLiteral)
|
export interface NumberLiteralType extends LiteralType {
|
||||||
export interface EnumLiteralType extends LiteralType {
|
value: number;
|
||||||
baseType: EnumType & UnionType; // Base enum type
|
}
|
||||||
|
|
||||||
|
// Enum types (TypeFlags.Enum)
|
||||||
|
export interface EnumType extends Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ObjectFlags {
|
export const enum ObjectFlags {
|
||||||
|
@ -3135,7 +3160,7 @@ namespace ts {
|
||||||
*/
|
*/
|
||||||
export interface TypeReference extends ObjectType {
|
export interface TypeReference extends ObjectType {
|
||||||
target: GenericType; // Type reference target
|
target: GenericType; // Type reference target
|
||||||
typeArguments: Type[]; // Type reference type arguments (undefined if none)
|
typeArguments?: Type[]; // Type reference type arguments (undefined if none)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic class and interface types
|
// Generic class and interface types
|
||||||
|
@ -3265,7 +3290,7 @@ namespace ts {
|
||||||
|
|
||||||
export interface Signature {
|
export interface Signature {
|
||||||
declaration: SignatureDeclaration; // Originating declaration
|
declaration: SignatureDeclaration; // Originating declaration
|
||||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
typeParameters?: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||||
parameters: Symbol[]; // Parameters
|
parameters: Symbol[]; // Parameters
|
||||||
/* @internal */
|
/* @internal */
|
||||||
thisParameter?: Symbol; // symbol of this-type parameter
|
thisParameter?: Symbol; // symbol of this-type parameter
|
||||||
|
@ -3527,7 +3552,7 @@ namespace ts {
|
||||||
|
|
||||||
export const enum NewLineKind {
|
export const enum NewLineKind {
|
||||||
CarriageReturnLineFeed = 0,
|
CarriageReturnLineFeed = 0,
|
||||||
LineFeed = 1,
|
LineFeed = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LineAndCharacter {
|
export interface LineAndCharacter {
|
||||||
|
@ -3946,7 +3971,7 @@ namespace ts {
|
||||||
commentRange?: TextRange; // The text range to use when emitting leading or trailing comments
|
commentRange?: TextRange; // The text range to use when emitting leading or trailing comments
|
||||||
sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings
|
sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings
|
||||||
tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens
|
tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens
|
||||||
constantValue?: number; // The constant value of an expression
|
constantValue?: string | number; // The constant value of an expression
|
||||||
externalHelpersModuleName?: Identifier; // The local name for an imported helpers module
|
externalHelpersModuleName?: Identifier; // The local name for an imported helpers module
|
||||||
helpers?: EmitHelper[]; // Emit helpers for the node
|
helpers?: EmitHelper[]; // Emit helpers for the node
|
||||||
}
|
}
|
||||||
|
@ -3979,6 +4004,7 @@ namespace ts {
|
||||||
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
||||||
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||||
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||||
|
NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions.
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EmitHelper {
|
export interface EmitHelper {
|
||||||
|
@ -4191,7 +4217,7 @@ namespace ts {
|
||||||
* Prints a bundle of source files as-is, without any emit transformations.
|
* Prints a bundle of source files as-is, without any emit transformations.
|
||||||
*/
|
*/
|
||||||
printBundle(bundle: Bundle): string;
|
printBundle(bundle: Bundle): string;
|
||||||
/*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, writer: EmitTextWriter): void;
|
/*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
||||||
/*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void;
|
/*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void;
|
||||||
/*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter): void;
|
/*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ namespace ts {
|
||||||
isTypeReferenceDirective?: boolean;
|
isTypeReferenceDirective?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
export function getDeclarationOfKind<T extends Declaration>(symbol: Symbol, kind: T["kind"]): T {
|
||||||
const declarations = symbol.declarations;
|
const declarations = symbol.declarations;
|
||||||
if (declarations) {
|
if (declarations) {
|
||||||
for (const declaration of declarations) {
|
for (const declaration of declarations) {
|
||||||
if (declaration.kind === kind) {
|
if (declaration.kind === kind) {
|
||||||
return declaration;
|
return declaration as T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,19 +328,21 @@ namespace ts {
|
||||||
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
return getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const escapeText = getEmitFlags(node) & EmitFlags.NoAsciiEscaping ? escapeString : escapeNonAsciiString;
|
||||||
|
|
||||||
// If we can't reach the original source text, use the canonical form if it's a number,
|
// If we can't reach the original source text, use the canonical form if it's a number,
|
||||||
// or an escaped quoted form of the original text if it's string-like.
|
// or a (possibly escaped) quoted form of the original text if it's string-like.
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case SyntaxKind.StringLiteral:
|
case SyntaxKind.StringLiteral:
|
||||||
return getQuotedEscapedLiteralText('"', node.text, '"');
|
return '"' + escapeText(node.text) + '"';
|
||||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||||
return getQuotedEscapedLiteralText("`", node.text, "`");
|
return "`" + escapeText(node.text) + "`";
|
||||||
case SyntaxKind.TemplateHead:
|
case SyntaxKind.TemplateHead:
|
||||||
return getQuotedEscapedLiteralText("`", node.text, "${");
|
return "`" + escapeText(node.text) + "${";
|
||||||
case SyntaxKind.TemplateMiddle:
|
case SyntaxKind.TemplateMiddle:
|
||||||
return getQuotedEscapedLiteralText("}", node.text, "${");
|
return "}" + escapeText(node.text) + "${";
|
||||||
case SyntaxKind.TemplateTail:
|
case SyntaxKind.TemplateTail:
|
||||||
return getQuotedEscapedLiteralText("}", node.text, "`");
|
return "}" + escapeText(node.text) + "`";
|
||||||
case SyntaxKind.NumericLiteral:
|
case SyntaxKind.NumericLiteral:
|
||||||
return node.text;
|
return node.text;
|
||||||
}
|
}
|
||||||
|
@ -348,8 +350,8 @@ namespace ts {
|
||||||
Debug.fail(`Literal kind '${node.kind}' not accounted for.`);
|
Debug.fail(`Literal kind '${node.kind}' not accounted for.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) {
|
export function getTextOfConstantValue(value: string | number) {
|
||||||
return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote;
|
return typeof value === "string" ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__'
|
||||||
|
@ -465,7 +467,7 @@ namespace ts {
|
||||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNameFromIndexInfo(info: IndexInfo) {
|
export function getNameFromIndexInfo(info: IndexInfo): string | undefined {
|
||||||
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
|
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,10 +591,6 @@ namespace ts {
|
||||||
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isDeclarationFile(file: SourceFile): boolean {
|
|
||||||
return file.isDeclarationFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isConstEnumDeclaration(node: Node): boolean {
|
export function isConstEnumDeclaration(node: Node): boolean {
|
||||||
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
return node.kind === SyntaxKind.EnumDeclaration && isConst(node);
|
||||||
}
|
}
|
||||||
|
@ -881,6 +879,16 @@ namespace ts {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode {
|
||||||
|
switch (node.kind) {
|
||||||
|
case SyntaxKind.FunctionType:
|
||||||
|
case SyntaxKind.ConstructorType:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export function introducesArgumentsExoticObject(node: Node) {
|
export function introducesArgumentsExoticObject(node: Node) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case SyntaxKind.MethodDeclaration:
|
case SyntaxKind.MethodDeclaration:
|
||||||
|
@ -2462,7 +2470,8 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
const nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
const nonAsciiCharacters = /[^\u0000-\u007F]/g;
|
||||||
export function escapeNonAsciiCharacters(s: string): string {
|
export function escapeNonAsciiString(s: string): string {
|
||||||
|
s = escapeString(s);
|
||||||
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
|
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
|
||||||
// Otherwise just return the original string.
|
// Otherwise just return the original string.
|
||||||
return nonAsciiCharacters.test(s) ?
|
return nonAsciiCharacters.test(s) ?
|
||||||
|
@ -2566,7 +2575,7 @@ namespace ts {
|
||||||
|
|
||||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string {
|
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string {
|
||||||
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
||||||
if (!file || isDeclarationFile(file)) {
|
if (!file || file.isDeclarationFile) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return getResolvedExternalModuleName(host, file);
|
return getResolvedExternalModuleName(host, file);
|
||||||
|
@ -2639,7 +2648,7 @@ namespace ts {
|
||||||
|
|
||||||
/** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
|
/** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */
|
||||||
export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) {
|
export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) {
|
||||||
return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile);
|
return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3255,13 +3264,13 @@ namespace ts {
|
||||||
const carriageReturnLineFeed = "\r\n";
|
const carriageReturnLineFeed = "\r\n";
|
||||||
const lineFeed = "\n";
|
const lineFeed = "\n";
|
||||||
export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string {
|
export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string {
|
||||||
if (options.newLine === NewLineKind.CarriageReturnLineFeed) {
|
switch (options.newLine) {
|
||||||
return carriageReturnLineFeed;
|
case NewLineKind.CarriageReturnLineFeed:
|
||||||
|
return carriageReturnLineFeed;
|
||||||
|
case NewLineKind.LineFeed:
|
||||||
|
return lineFeed;
|
||||||
}
|
}
|
||||||
else if (options.newLine === NewLineKind.LineFeed) {
|
if (sys) {
|
||||||
return lineFeed;
|
|
||||||
}
|
|
||||||
else if (sys) {
|
|
||||||
return sys.newLine;
|
return sys.newLine;
|
||||||
}
|
}
|
||||||
return carriageReturnLineFeed;
|
return carriageReturnLineFeed;
|
||||||
|
@ -4010,6 +4019,10 @@ namespace ts {
|
||||||
return node.kind === SyntaxKind.ImportEqualsDeclaration;
|
return node.kind === SyntaxKind.ImportEqualsDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isImportDeclaration(node: Node): node is ImportDeclaration {
|
||||||
|
return node.kind === SyntaxKind.ImportDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
export function isImportClause(node: Node): node is ImportClause {
|
export function isImportClause(node: Node): node is ImportClause {
|
||||||
return node.kind === SyntaxKind.ImportClause;
|
return node.kind === SyntaxKind.ImportClause;
|
||||||
}
|
}
|
||||||
|
@ -4032,6 +4045,10 @@ namespace ts {
|
||||||
return node.kind === SyntaxKind.ExportSpecifier;
|
return node.kind === SyntaxKind.ExportSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isExportAssignment(node: Node): node is ExportAssignment {
|
||||||
|
return node.kind === SyntaxKind.ExportAssignment;
|
||||||
|
}
|
||||||
|
|
||||||
export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration {
|
export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration {
|
||||||
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
|
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,10 @@ namespace ts {
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
// Names
|
// Names
|
||||||
|
|
||||||
|
case SyntaxKind.Identifier:
|
||||||
|
return updateIdentifier(<Identifier>node, nodesVisitor((<Identifier>node).typeArguments, visitor, isTypeNode));
|
||||||
|
|
||||||
case SyntaxKind.QualifiedName:
|
case SyntaxKind.QualifiedName:
|
||||||
return updateQualifiedName(<QualifiedName>node,
|
return updateQualifiedName(<QualifiedName>node,
|
||||||
visitNode((<QualifiedName>node).left, visitor, isEntityName),
|
visitNode((<QualifiedName>node).left, visitor, isEntityName),
|
||||||
|
@ -255,6 +259,7 @@ namespace ts {
|
||||||
|
|
||||||
case SyntaxKind.PropertySignature:
|
case SyntaxKind.PropertySignature:
|
||||||
return updatePropertySignature((<PropertySignature>node),
|
return updatePropertySignature((<PropertySignature>node),
|
||||||
|
nodesVisitor((<PropertySignature>node).modifiers, visitor, isToken),
|
||||||
visitNode((<PropertySignature>node).name, visitor, isPropertyName),
|
visitNode((<PropertySignature>node).name, visitor, isPropertyName),
|
||||||
visitNode((<PropertySignature>node).questionToken, tokenVisitor, isToken),
|
visitNode((<PropertySignature>node).questionToken, tokenVisitor, isToken),
|
||||||
visitNode((<PropertySignature>node).type, visitor, isTypeNode),
|
visitNode((<PropertySignature>node).type, visitor, isTypeNode),
|
||||||
|
@ -970,6 +975,15 @@ namespace ts {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Type member
|
// Type member
|
||||||
|
|
||||||
|
case SyntaxKind.PropertySignature:
|
||||||
|
result = reduceNodes((<PropertySignature>node).modifiers, cbNodes, result);
|
||||||
|
result = reduceNode((<PropertySignature>node).name, cbNode, result);
|
||||||
|
result = reduceNode((<PropertySignature>node).questionToken, cbNode, result);
|
||||||
|
result = reduceNode((<PropertySignature>node).type, cbNode, result);
|
||||||
|
result = reduceNode((<PropertySignature>node).initializer, cbNode, result);
|
||||||
|
break;
|
||||||
|
|
||||||
case SyntaxKind.PropertyDeclaration:
|
case SyntaxKind.PropertyDeclaration:
|
||||||
result = reduceNodes((<PropertyDeclaration>node).decorators, cbNodes, result);
|
result = reduceNodes((<PropertyDeclaration>node).decorators, cbNodes, result);
|
||||||
result = reduceNodes((<PropertyDeclaration>node).modifiers, cbNodes, result);
|
result = reduceNodes((<PropertyDeclaration>node).modifiers, cbNodes, result);
|
||||||
|
|
|
@ -372,7 +372,7 @@ class ProjectRunner extends RunnerBase {
|
||||||
const compilerOptions = compilerResult.program.getCompilerOptions();
|
const compilerOptions = compilerResult.program.getCompilerOptions();
|
||||||
|
|
||||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||||
if (ts.isDeclarationFile(sourceFile)) {
|
if (sourceFile.isDeclarationFile) {
|
||||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||||
}
|
}
|
||||||
else if (!(compilerOptions.outFile || compilerOptions.out)) {
|
else if (!(compilerOptions.outFile || compilerOptions.out)) {
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace ts.codefix {
|
||||||
}
|
}
|
||||||
|
|
||||||
function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) {
|
function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) {
|
||||||
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration);
|
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.SuppressAnyReturnType);
|
||||||
if (signatureDeclaration) {
|
if (signatureDeclaration) {
|
||||||
signatureDeclaration.decorators = undefined;
|
signatureDeclaration.decorators = undefined;
|
||||||
signatureDeclaration.modifiers = modifiers;
|
signatureDeclaration.modifiers = modifiers;
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace ts.Completions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type.flags & TypeFlags.StringLiteral) {
|
else if (type.flags & TypeFlags.StringLiteral) {
|
||||||
const name = (<LiteralType>type).text;
|
const name = (<StringLiteralType>type).value;
|
||||||
if (!uniques.has(name)) {
|
if (!uniques.has(name)) {
|
||||||
uniques.set(name, true);
|
uniques.set(name, true);
|
||||||
result.push({
|
result.push({
|
||||||
|
@ -359,7 +359,7 @@ namespace ts.Completions {
|
||||||
|
|
||||||
start = timestamp();
|
start = timestamp();
|
||||||
// Completion not allowed inside comments, bail out if this is the case
|
// Completion not allowed inside comments, bail out if this is the case
|
||||||
const insideComment = isInsideComment(sourceFile, currentToken, position);
|
const insideComment = isInComment(sourceFile, position, currentToken);
|
||||||
log("getCompletionData: Is inside comment: " + (timestamp() - start));
|
log("getCompletionData: Is inside comment: " + (timestamp() - start));
|
||||||
|
|
||||||
if (insideComment) {
|
if (insideComment) {
|
||||||
|
|
|
@ -550,7 +550,7 @@ namespace ts.FindAllReferences.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean {
|
function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean {
|
||||||
const bindingElement = <BindingElement>getDeclarationOfKind(symbol, SyntaxKind.BindingElement);
|
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||||
return bindingElement &&
|
return bindingElement &&
|
||||||
bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern &&
|
bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern &&
|
||||||
!bindingElement.propertyName;
|
!bindingElement.propertyName;
|
||||||
|
@ -558,7 +558,7 @@ namespace ts.FindAllReferences.Core {
|
||||||
|
|
||||||
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined {
|
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined {
|
||||||
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
|
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
|
||||||
const bindingElement = <BindingElement>getDeclarationOfKind(symbol, SyntaxKind.BindingElement);
|
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||||
const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent);
|
const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent);
|
||||||
return typeOfPattern && checker.getPropertyOfType(typeOfPattern, (<Identifier>bindingElement.name).text);
|
return typeOfPattern && checker.getPropertyOfType(typeOfPattern, (<Identifier>bindingElement.name).text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,17 +526,18 @@ namespace ts.FindAllReferences {
|
||||||
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
|
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function symbolName(symbol: Symbol): string {
|
function symbolName(symbol: Symbol): string | undefined {
|
||||||
if (symbol.name !== "default") {
|
if (symbol.name !== "default") {
|
||||||
return symbol.name;
|
return symbol.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = forEach(symbol.declarations, decl => {
|
return forEach(symbol.declarations, decl => {
|
||||||
|
if (isExportAssignment(decl)) {
|
||||||
|
return isIdentifier(decl.expression) ? decl.expression.text : undefined;
|
||||||
|
}
|
||||||
const name = getNameOfDeclaration(decl);
|
const name = getNameOfDeclaration(decl);
|
||||||
return name && name.kind === SyntaxKind.Identifier && name.text;
|
return name && name.kind === SyntaxKind.Identifier && name.text;
|
||||||
});
|
});
|
||||||
Debug.assert(!!name);
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If at an export specifier, go to the symbol it refers to. */
|
/** If at an export specifier, go to the symbol it refers to. */
|
||||||
|
|
|
@ -360,6 +360,7 @@ namespace ts {
|
||||||
_incrementExpressionBrand: any;
|
_incrementExpressionBrand: any;
|
||||||
_unaryExpressionBrand: any;
|
_unaryExpressionBrand: any;
|
||||||
_expressionBrand: any;
|
_expressionBrand: any;
|
||||||
|
/*@internal*/typeArguments: NodeArray<TypeNode>;
|
||||||
constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) {
|
constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) {
|
||||||
super(pos, end);
|
super(pos, end);
|
||||||
}
|
}
|
||||||
|
@ -1853,8 +1854,8 @@ namespace ts {
|
||||||
|
|
||||||
// OK, we have found a match in the file. This is only an acceptable match if
|
// OK, we have found a match in the file. This is only an acceptable match if
|
||||||
// it is contained within a comment.
|
// it is contained within a comment.
|
||||||
const token = getTokenAtPosition(sourceFile, matchPosition);
|
|
||||||
if (!isInsideComment(sourceFile, token, matchPosition)) {
|
if (!isInComment(sourceFile, matchPosition)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace ts.SymbolDisplay {
|
||||||
}
|
}
|
||||||
if (symbolFlags & SymbolFlags.Module) {
|
if (symbolFlags & SymbolFlags.Module) {
|
||||||
addNewLineIfDisplayPartsExist();
|
addNewLineIfDisplayPartsExist();
|
||||||
const declaration = <ModuleDeclaration>getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration);
|
const declaration = getDeclarationOfKind<ModuleDeclaration>(symbol, SyntaxKind.ModuleDeclaration);
|
||||||
const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier;
|
const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier;
|
||||||
displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword));
|
displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword));
|
||||||
displayParts.push(spacePart());
|
displayParts.push(spacePart());
|
||||||
|
@ -296,9 +296,9 @@ namespace ts.SymbolDisplay {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Method/function type parameter
|
// Method/function type parameter
|
||||||
let declaration = <Node>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter);
|
const decl = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter);
|
||||||
Debug.assert(declaration !== undefined);
|
Debug.assert(decl !== undefined);
|
||||||
declaration = declaration.parent;
|
const declaration = decl.parent;
|
||||||
|
|
||||||
if (declaration) {
|
if (declaration) {
|
||||||
if (isFunctionLikeKind(declaration.kind)) {
|
if (isFunctionLikeKind(declaration.kind)) {
|
||||||
|
@ -336,7 +336,8 @@ namespace ts.SymbolDisplay {
|
||||||
displayParts.push(spacePart());
|
displayParts.push(spacePart());
|
||||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||||
displayParts.push(spacePart());
|
displayParts.push(spacePart());
|
||||||
displayParts.push(displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral));
|
displayParts.push(displayPart(getTextOfConstantValue(constantValue),
|
||||||
|
typeof constantValue === "number" ? SymbolDisplayPartKind.numericLiteral : SymbolDisplayPartKind.stringLiteral));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,8 +497,8 @@ namespace ts.textChanges {
|
||||||
readonly node: Node;
|
readonly node: Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNonformattedText(node: Node, sourceFile: SourceFile, newLine: NewLineKind): NonFormattedText {
|
export function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText {
|
||||||
const options = { newLine, target: sourceFile.languageVersion };
|
const options = { newLine, target: sourceFile && sourceFile.languageVersion };
|
||||||
const writer = new Writer(getNewLineCharacter(options));
|
const writer = new Writer(getNewLineCharacter(options));
|
||||||
const printer = createPrinter(options, writer);
|
const printer = createPrinter(options, writer);
|
||||||
printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer);
|
printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer);
|
||||||
|
@ -528,26 +528,6 @@ namespace ts.textChanges {
|
||||||
return skipTrivia(s, 0) === s.length;
|
return skipTrivia(s, 0) === s.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nullTransformationContext: TransformationContext = {
|
|
||||||
enableEmitNotification: noop,
|
|
||||||
enableSubstitution: noop,
|
|
||||||
endLexicalEnvironment: () => undefined,
|
|
||||||
getCompilerOptions: notImplemented,
|
|
||||||
getEmitHost: notImplemented,
|
|
||||||
getEmitResolver: notImplemented,
|
|
||||||
hoistFunctionDeclaration: noop,
|
|
||||||
hoistVariableDeclaration: noop,
|
|
||||||
isEmitNotificationEnabled: notImplemented,
|
|
||||||
isSubstitutionEnabled: notImplemented,
|
|
||||||
onEmitNode: noop,
|
|
||||||
onSubstituteNode: notImplemented,
|
|
||||||
readEmitHelpers: notImplemented,
|
|
||||||
requestEmitHelper: noop,
|
|
||||||
resumeLexicalEnvironment: noop,
|
|
||||||
startLexicalEnvironment: noop,
|
|
||||||
suspendLexicalEnvironment: noop
|
|
||||||
};
|
|
||||||
|
|
||||||
function assignPositionsToNode(node: Node): Node {
|
function assignPositionsToNode(node: Node): Node {
|
||||||
const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
||||||
// create proxy node for non synthesized nodes
|
// create proxy node for non synthesized nodes
|
||||||
|
|
|
@ -256,37 +256,6 @@ namespace ts {
|
||||||
getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node;
|
getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the position is within a comment */
|
|
||||||
export function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean {
|
|
||||||
// The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment
|
|
||||||
return position <= token.getStart(sourceFile) &&
|
|
||||||
(isInsideCommentRange(getTrailingCommentRanges(sourceFile.text, token.getFullStart())) ||
|
|
||||||
isInsideCommentRange(getLeadingCommentRanges(sourceFile.text, token.getFullStart())));
|
|
||||||
|
|
||||||
function isInsideCommentRange(comments: CommentRange[]): boolean {
|
|
||||||
return forEach(comments, comment => {
|
|
||||||
// either we are 1. completely inside the comment, or 2. at the end of the comment
|
|
||||||
if (comment.pos < position && position < comment.end) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (position === comment.end) {
|
|
||||||
const text = sourceFile.text;
|
|
||||||
const width = comment.end - comment.pos;
|
|
||||||
// is single line comment or just /*
|
|
||||||
if (width <= 2 || text.charCodeAt(comment.pos + 1) === CharacterCodes.slash) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// is unterminated multi-line comment
|
|
||||||
return !(text.charCodeAt(comment.end - 1) === CharacterCodes.slash &&
|
|
||||||
text.charCodeAt(comment.end - 2) === CharacterCodes.asterisk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getContainerNode(node: Node): Declaration {
|
export function getContainerNode(node: Node): Declaration {
|
||||||
while (true) {
|
while (true) {
|
||||||
node = node.parent;
|
node = node.parent;
|
||||||
|
@ -651,44 +620,26 @@ namespace ts {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeJsDocComment) {
|
|
||||||
const jsDocChildren = ts.filter(current.getChildren(), isJSDocNode);
|
|
||||||
for (const jsDocChild of jsDocChildren) {
|
|
||||||
const start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment);
|
|
||||||
if (start <= position) {
|
|
||||||
const end = jsDocChild.getEnd();
|
|
||||||
if (position < end || (position === end && jsDocChild.kind === SyntaxKind.EndOfFileToken)) {
|
|
||||||
current = jsDocChild;
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
else if (includeItemAtEndPosition && end === position) {
|
|
||||||
const previousToken = findPrecedingToken(position, sourceFile, jsDocChild);
|
|
||||||
if (previousToken && includeItemAtEndPosition(previousToken)) {
|
|
||||||
return previousToken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the child that contains 'position'
|
// find the child that contains 'position'
|
||||||
for (const child of current.getChildren()) {
|
for (const child of current.getChildren()) {
|
||||||
// all jsDocComment nodes were already visited
|
if (isJSDocNode(child) && !includeJsDocComment) {
|
||||||
if (isJSDocNode(child)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment);
|
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment);
|
||||||
if (start <= position) {
|
if (start > position) {
|
||||||
const end = child.getEnd();
|
continue;
|
||||||
if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) {
|
}
|
||||||
current = child;
|
|
||||||
continue outer;
|
const end = child.getEnd();
|
||||||
}
|
if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) {
|
||||||
else if (includeItemAtEndPosition && end === position) {
|
current = child;
|
||||||
const previousToken = findPrecedingToken(position, sourceFile, child);
|
continue outer;
|
||||||
if (previousToken && includeItemAtEndPosition(previousToken)) {
|
}
|
||||||
return previousToken;
|
else if (includeItemAtEndPosition && end === position) {
|
||||||
}
|
const previousToken = findPrecedingToken(position, sourceFile, child);
|
||||||
|
if (previousToken && includeItemAtEndPosition(previousToken)) {
|
||||||
|
return previousToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -834,10 +785,6 @@ namespace ts {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isInComment(sourceFile: SourceFile, position: number) {
|
|
||||||
return isInCommentHelper(sourceFile, position, /*predicate*/ undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the position is in between the open and close elements of an JSX expression.
|
* returns true if the position is in between the open and close elements of an JSX expression.
|
||||||
*/
|
*/
|
||||||
|
@ -883,15 +830,26 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the cursor at position in sourceFile is within a comment that additionally
|
* Returns true if the cursor at position in sourceFile is within a comment.
|
||||||
* satisfies predicate, and false otherwise.
|
*
|
||||||
|
* @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position)
|
||||||
|
* @param predicate Additional predicate to test on the comment range.
|
||||||
*/
|
*/
|
||||||
export function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean {
|
export function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition = getTokenAtPosition(sourceFile, position), predicate?: (c: CommentRange) => boolean): boolean {
|
||||||
const token = getTokenAtPosition(sourceFile, position);
|
return position <= tokenAtPosition.getStart(sourceFile) &&
|
||||||
|
(isInCommentRange(getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) ||
|
||||||
|
isInCommentRange(getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos)));
|
||||||
|
|
||||||
if (token && position <= token.getStart(sourceFile)) {
|
function isInCommentRange(commentRanges: CommentRange[]): boolean {
|
||||||
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
return forEach(commentRanges, c => isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPositionInCommentRange({ pos, end, kind }: ts.CommentRange, position: number, text: string): boolean {
|
||||||
|
if (pos < position && position < end) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (position === end) {
|
||||||
// The end marker of a single-line comment does not include the newline character.
|
// The end marker of a single-line comment does not include the newline character.
|
||||||
// In the following case, we are inside a comment (^ denotes the cursor position):
|
// In the following case, we are inside a comment (^ denotes the cursor position):
|
||||||
//
|
//
|
||||||
|
@ -902,15 +860,13 @@ namespace ts {
|
||||||
// /* asdf */^
|
// /* asdf */^
|
||||||
//
|
//
|
||||||
// Internally, we represent the end of the comment at the newline and closing '/', respectively.
|
// Internally, we represent the end of the comment at the newline and closing '/', respectively.
|
||||||
return predicate ?
|
return kind === SyntaxKind.SingleLineCommentTrivia ||
|
||||||
forEach(commentRanges, c => c.pos < position &&
|
// true for unterminated multi-line comment
|
||||||
(c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end) &&
|
!(text.charCodeAt(end - 1) === CharacterCodes.slash && text.charCodeAt(end - 2) === CharacterCodes.asterisk);
|
||||||
predicate(c)) :
|
}
|
||||||
forEach(commentRanges, c => c.pos < position &&
|
else {
|
||||||
(c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasDocComment(sourceFile: SourceFile, position: number) {
|
export function hasDocComment(sourceFile: SourceFile, position: number) {
|
||||||
|
@ -1093,21 +1049,17 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
|
export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean {
|
||||||
return isInCommentHelper(sourceFile, position, isReferenceComment);
|
return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => {
|
||||||
|
|
||||||
function isReferenceComment(c: CommentRange): boolean {
|
|
||||||
const commentText = sourceFile.text.substring(c.pos, c.end);
|
const commentText = sourceFile.text.substring(c.pos, c.end);
|
||||||
return tripleSlashDirectivePrefixRegex.test(commentText);
|
return tripleSlashDirectivePrefixRegex.test(commentText);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
|
export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean {
|
||||||
return isInCommentHelper(sourceFile, position, isNonReferenceComment);
|
return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => {
|
||||||
|
|
||||||
function isNonReferenceComment(c: CommentRange): boolean {
|
|
||||||
const commentText = sourceFile.text.substring(c.pos, c.end);
|
const commentText = sourceFile.text.substring(c.pos, c.end);
|
||||||
return !tripleSlashDirectivePrefixRegex.test(commentText);
|
return !tripleSlashDirectivePrefixRegex.test(commentText);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan {
|
export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan {
|
||||||
|
|
|
@ -98,8 +98,8 @@ var e3 = t3[2]; // any
|
||||||
>2 : 2
|
>2 : 2
|
||||||
|
|
||||||
var e4 = t4[3]; // number
|
var e4 = t4[3]; // number
|
||||||
>e4 : number | E1 | E2
|
>e4 : number
|
||||||
>t4[3] : number | E1 | E2
|
>t4[3] : number
|
||||||
>t4 : [E1, E2, number]
|
>t4 : [E1, E2, number]
|
||||||
>3 : 3
|
>3 : 3
|
||||||
|
|
||||||
|
|
81
tests/baselines/reference/callWithSpread2.errors.txt
Normal file
81
tests/baselines/reference/callWithSpread2.errors.txt
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(37,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(38,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (9 errors) ====
|
||||||
|
declare function all(a?: number, b?: number): void;
|
||||||
|
declare function weird(a?: number | string, b?: number | string): void;
|
||||||
|
declare function prefix(s: string, a?: number, b?: number): void;
|
||||||
|
declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void;
|
||||||
|
declare function normal(s: string): void;
|
||||||
|
declare function thunk(): string;
|
||||||
|
|
||||||
|
declare var ns: number[];
|
||||||
|
declare var mixed: (number | string)[];
|
||||||
|
declare var tuple: [number, string];
|
||||||
|
|
||||||
|
// good
|
||||||
|
all(...ns)
|
||||||
|
weird(...ns)
|
||||||
|
weird(...mixed)
|
||||||
|
weird(...tuple)
|
||||||
|
prefix("a", ...ns)
|
||||||
|
rest("d", ...ns)
|
||||||
|
|
||||||
|
|
||||||
|
// this covers the arguments case
|
||||||
|
normal("g", ...ns)
|
||||||
|
normal("h", ...mixed)
|
||||||
|
normal("i", ...tuple)
|
||||||
|
thunk(...ns)
|
||||||
|
thunk(...mixed)
|
||||||
|
thunk(...tuple)
|
||||||
|
|
||||||
|
// bad
|
||||||
|
all(...mixed)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
all(...tuple)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
prefix("b", ...mixed)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
prefix("c", ...tuple)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
rest("e", ...mixed)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
rest("f", ...tuple)
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
|
||||||
|
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||||
|
prefix(...ns) // required parameters are required
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
prefix(...mixed)
|
||||||
|
~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
prefix(...tuple)
|
||||||
|
~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||||
|
|
66
tests/baselines/reference/callWithSpread2.js
Normal file
66
tests/baselines/reference/callWithSpread2.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
//// [callWithSpread2.ts]
|
||||||
|
declare function all(a?: number, b?: number): void;
|
||||||
|
declare function weird(a?: number | string, b?: number | string): void;
|
||||||
|
declare function prefix(s: string, a?: number, b?: number): void;
|
||||||
|
declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void;
|
||||||
|
declare function normal(s: string): void;
|
||||||
|
declare function thunk(): string;
|
||||||
|
|
||||||
|
declare var ns: number[];
|
||||||
|
declare var mixed: (number | string)[];
|
||||||
|
declare var tuple: [number, string];
|
||||||
|
|
||||||
|
// good
|
||||||
|
all(...ns)
|
||||||
|
weird(...ns)
|
||||||
|
weird(...mixed)
|
||||||
|
weird(...tuple)
|
||||||
|
prefix("a", ...ns)
|
||||||
|
rest("d", ...ns)
|
||||||
|
|
||||||
|
|
||||||
|
// this covers the arguments case
|
||||||
|
normal("g", ...ns)
|
||||||
|
normal("h", ...mixed)
|
||||||
|
normal("i", ...tuple)
|
||||||
|
thunk(...ns)
|
||||||
|
thunk(...mixed)
|
||||||
|
thunk(...tuple)
|
||||||
|
|
||||||
|
// bad
|
||||||
|
all(...mixed)
|
||||||
|
all(...tuple)
|
||||||
|
prefix("b", ...mixed)
|
||||||
|
prefix("c", ...tuple)
|
||||||
|
rest("e", ...mixed)
|
||||||
|
rest("f", ...tuple)
|
||||||
|
prefix(...ns) // required parameters are required
|
||||||
|
prefix(...mixed)
|
||||||
|
prefix(...tuple)
|
||||||
|
|
||||||
|
|
||||||
|
//// [callWithSpread2.js]
|
||||||
|
// good
|
||||||
|
all.apply(void 0, ns);
|
||||||
|
weird.apply(void 0, ns);
|
||||||
|
weird.apply(void 0, mixed);
|
||||||
|
weird.apply(void 0, tuple);
|
||||||
|
prefix.apply(void 0, ["a"].concat(ns));
|
||||||
|
rest.apply(void 0, ["d"].concat(ns));
|
||||||
|
// this covers the arguments case
|
||||||
|
normal.apply(void 0, ["g"].concat(ns));
|
||||||
|
normal.apply(void 0, ["h"].concat(mixed));
|
||||||
|
normal.apply(void 0, ["i"].concat(tuple));
|
||||||
|
thunk.apply(void 0, ns);
|
||||||
|
thunk.apply(void 0, mixed);
|
||||||
|
thunk.apply(void 0, tuple);
|
||||||
|
// bad
|
||||||
|
all.apply(void 0, mixed);
|
||||||
|
all.apply(void 0, tuple);
|
||||||
|
prefix.apply(void 0, ["b"].concat(mixed));
|
||||||
|
prefix.apply(void 0, ["c"].concat(tuple));
|
||||||
|
rest.apply(void 0, ["e"].concat(mixed));
|
||||||
|
rest.apply(void 0, ["f"].concat(tuple));
|
||||||
|
prefix.apply(void 0, ns); // required parameters are required
|
||||||
|
prefix.apply(void 0, mixed);
|
||||||
|
prefix.apply(void 0, tuple);
|
|
@ -12,7 +12,7 @@ var o = {
|
||||||
>{ [E1.x || E2.x]: 0} : { [x: number]: number; }
|
>{ [E1.x || E2.x]: 0} : { [x: number]: number; }
|
||||||
|
|
||||||
[E1.x || E2.x]: 0
|
[E1.x || E2.x]: 0
|
||||||
>E1.x || E2.x : E1 | E2
|
>E1.x || E2.x : E2
|
||||||
>E1.x : E1
|
>E1.x : E1
|
||||||
>E1 : typeof E1
|
>E1 : typeof E1
|
||||||
>x : E1
|
>x : E1
|
||||||
|
|
|
@ -12,7 +12,7 @@ var o = {
|
||||||
>{ [E1.x || E2.x]: 0} : { [x: number]: number; }
|
>{ [E1.x || E2.x]: 0} : { [x: number]: number; }
|
||||||
|
|
||||||
[E1.x || E2.x]: 0
|
[E1.x || E2.x]: 0
|
||||||
>E1.x || E2.x : E1 | E2
|
>E1.x || E2.x : E2
|
||||||
>E1.x : E1
|
>E1.x : E1
|
||||||
>E1 : typeof E1
|
>E1 : typeof E1
|
||||||
>x : E1
|
>x : E1
|
||||||
|
|
|
@ -128,8 +128,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -169,8 +169,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
class C5 {
|
class C5 {
|
||||||
f() {
|
f() {
|
||||||
|
|
|
@ -264,8 +264,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -354,8 +354,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __values = (this && this.__values) || function (o) {
|
var __values = (this && this.__values) || function (o) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
|
|
@ -91,8 +91,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -130,8 +130,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
function f5() {
|
function f5() {
|
||||||
return __asyncGenerator(this, arguments, function* f5_1() {
|
return __asyncGenerator(this, arguments, function* f5_1() {
|
||||||
|
|
|
@ -218,8 +218,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -303,8 +303,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __values = (this && this.__values) || function (o) {
|
var __values = (this && this.__values) || function (o) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
|
|
@ -91,8 +91,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -130,8 +130,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
const f5 = function () {
|
const f5 = function () {
|
||||||
return __asyncGenerator(this, arguments, function* () {
|
return __asyncGenerator(this, arguments, function* () {
|
||||||
|
|
|
@ -218,8 +218,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -303,8 +303,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __values = (this && this.__values) || function (o) {
|
var __values = (this && this.__values) || function (o) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
|
|
@ -111,8 +111,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -152,8 +152,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
const o5 = {
|
const o5 = {
|
||||||
f() {
|
f() {
|
||||||
|
|
|
@ -238,8 +238,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
@ -325,8 +325,8 @@ var __asyncValues = (this && this.__asyncIterator) || function (o) {
|
||||||
};
|
};
|
||||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||||
var i, p;
|
var i, p;
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
|
||||||
};
|
};
|
||||||
var __values = (this && this.__values) || function (o) {
|
var __values = (this && this.__values) || function (o) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(68,1): error TS2324: Property 'd' is missing in type 'First.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(68,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
|
||||||
|
Property 'd' is missing in type 'First.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
|
||||||
Property 'd' is missing in type 'First.E'.
|
Property 'd' is missing in type 'First.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(71,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(71,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(72,1): error TS2322: Type 'Decl.E' is not assignable to type 'First.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(72,1): error TS2322: Type 'Decl.E' is not assignable to type 'First.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(75,1): error TS2324: Property 'c' is missing in type 'Ab.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(75,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
|
||||||
|
Property 'c' is missing in type 'Ab.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(76,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(76,1): error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
|
||||||
|
Property 'a' is missing in type 'Cd.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(77,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(77,1): error TS2322: Type 'E' is not assignable to type 'Nope'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(78,1): error TS2322: Type 'First.E' is not assignable to type 'Decl.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(78,1): error TS2322: Type 'First.E' is not assignable to type 'Decl.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(82,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(82,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(83,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(83,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'.
|
||||||
tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2324: Property 'd' is missing in type 'First.E'.
|
tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
|
||||||
|
Property 'd' is missing in type 'First.E'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/enumAssignmentCompat3.ts (11 errors) ====
|
==== tests/cases/compiler/enumAssignmentCompat3.ts (11 errors) ====
|
||||||
|
@ -82,7 +86,8 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2324: Property 'd'
|
||||||
abc = secondAbc; // ok
|
abc = secondAbc; // ok
|
||||||
abc = secondAbcd; // missing 'd'
|
abc = secondAbcd; // missing 'd'
|
||||||
~~~
|
~~~
|
||||||
!!! error TS2324: Property 'd' is missing in type 'First.E'.
|
!!! error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
|
||||||
|
!!! error TS2322: Property 'd' is missing in type 'First.E'.
|
||||||
abc = secondAb; // ok
|
abc = secondAb; // ok
|
||||||
abc = secondCd; // missing 'd'
|
abc = secondCd; // missing 'd'
|
||||||
~~~
|
~~~
|
||||||
|
@ -98,10 +103,12 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2324: Property 'd'
|
||||||
secondAbcd = abc; // ok
|
secondAbcd = abc; // ok
|
||||||
secondAb = abc; // missing 'c'
|
secondAb = abc; // missing 'c'
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! error TS2324: Property 'c' is missing in type 'Ab.E'.
|
!!! error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
|
||||||
|
!!! error TS2322: Property 'c' is missing in type 'Ab.E'.
|
||||||
secondCd = abc; // missing 'a' and 'b'
|
secondCd = abc; // missing 'a' and 'b'
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
|
!!! error TS2322: Type 'First.E' is not assignable to type 'Cd.E'.
|
||||||
|
!!! error TS2322: Property 'a' is missing in type 'Cd.E'.
|
||||||
nope = abc; // nope!
|
nope = abc; // nope!
|
||||||
~~~~
|
~~~~
|
||||||
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
|
!!! error TS2322: Type 'E' is not assignable to type 'Nope'.
|
||||||
|
@ -121,7 +128,8 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2324: Property 'd'
|
||||||
// merged enums compare all their members
|
// merged enums compare all their members
|
||||||
abc = merged; // missing 'd'
|
abc = merged; // missing 'd'
|
||||||
~~~
|
~~~
|
||||||
!!! error TS2324: Property 'd' is missing in type 'First.E'.
|
!!! error TS2322: Type 'Merged.E' is not assignable to type 'First.E'.
|
||||||
|
!!! error TS2322: Property 'd' is missing in type 'First.E'.
|
||||||
merged = abc; // ok
|
merged = abc; // ok
|
||||||
abc = merged2; // ok
|
abc = merged2; // ok
|
||||||
merged2 = abc; // ok
|
merged2 = abc; // ok
|
|
@ -1,86 +0,0 @@
|
||||||
tests/cases/conformance/enums/enumBasics.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'.
|
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/enums/enumBasics.ts (1 errors) ====
|
|
||||||
// Enum without initializers have first member = 0 and successive members = N + 1
|
|
||||||
enum E1 {
|
|
||||||
A,
|
|
||||||
B,
|
|
||||||
C
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum type is a subtype of Number
|
|
||||||
var x: number = E1.A;
|
|
||||||
|
|
||||||
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
|
||||||
var e = E1;
|
|
||||||
var e: {
|
|
||||||
~
|
|
||||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'.
|
|
||||||
readonly A: E1;
|
|
||||||
readonly B: E1;
|
|
||||||
readonly C: E1;
|
|
||||||
readonly [n: number]: string;
|
|
||||||
};
|
|
||||||
var e: typeof E1;
|
|
||||||
|
|
||||||
// Reverse mapping of enum returns string name of property
|
|
||||||
var s = E1[e.A];
|
|
||||||
var s: string;
|
|
||||||
|
|
||||||
|
|
||||||
// Enum with only constant members
|
|
||||||
enum E2 {
|
|
||||||
A = 1, B = 2, C = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum with only computed members
|
|
||||||
enum E3 {
|
|
||||||
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum with constant members followed by computed members
|
|
||||||
enum E4 {
|
|
||||||
X = 0, Y, Z = 'foo'.length
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum with > 2 constant members with no initializer for first member, non zero initializer for second element
|
|
||||||
enum E5 {
|
|
||||||
A,
|
|
||||||
B = 3,
|
|
||||||
C // 4
|
|
||||||
}
|
|
||||||
|
|
||||||
enum E6 {
|
|
||||||
A,
|
|
||||||
B = 0,
|
|
||||||
C // 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum with computed member initializer of type 'any'
|
|
||||||
enum E7 {
|
|
||||||
A = 'foo'['foo']
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum with computed member initializer of type number
|
|
||||||
enum E8 {
|
|
||||||
B = 'foo'['foo']
|
|
||||||
}
|
|
||||||
|
|
||||||
//Enum with computed member intializer of same enum type
|
|
||||||
enum E9 {
|
|
||||||
A,
|
|
||||||
B = A
|
|
||||||
}
|
|
||||||
|
|
||||||
// (refer to .js to validate)
|
|
||||||
// Enum constant members are propagated
|
|
||||||
var doNotPropagate = [
|
|
||||||
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
|
|
||||||
];
|
|
||||||
// Enum computed members are not propagated
|
|
||||||
var doPropagate = [
|
|
||||||
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ var x: number = E1.A;
|
||||||
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
||||||
var e = E1;
|
var e = E1;
|
||||||
var e: {
|
var e: {
|
||||||
readonly A: E1;
|
readonly A: E1.A;
|
||||||
readonly B: E1;
|
readonly B: E1.B;
|
||||||
readonly C: E1;
|
readonly C: E1.C;
|
||||||
readonly [n: number]: string;
|
readonly [n: number]: string;
|
||||||
};
|
};
|
||||||
var e: typeof E1;
|
var e: typeof E1;
|
||||||
|
|
|
@ -28,17 +28,20 @@ var e = E1;
|
||||||
var e: {
|
var e: {
|
||||||
>e : Symbol(e, Decl(enumBasics.ts, 11, 3), Decl(enumBasics.ts, 12, 3), Decl(enumBasics.ts, 18, 3))
|
>e : Symbol(e, Decl(enumBasics.ts, 11, 3), Decl(enumBasics.ts, 12, 3), Decl(enumBasics.ts, 18, 3))
|
||||||
|
|
||||||
readonly A: E1;
|
readonly A: E1.A;
|
||||||
>A : Symbol(A, Decl(enumBasics.ts, 12, 8))
|
>A : Symbol(A, Decl(enumBasics.ts, 12, 8))
|
||||||
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
||||||
|
>A : Symbol(E1.A, Decl(enumBasics.ts, 1, 9))
|
||||||
|
|
||||||
readonly B: E1;
|
readonly B: E1.B;
|
||||||
>B : Symbol(B, Decl(enumBasics.ts, 13, 19))
|
>B : Symbol(B, Decl(enumBasics.ts, 13, 21))
|
||||||
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
||||||
|
>B : Symbol(E1.B, Decl(enumBasics.ts, 2, 6))
|
||||||
|
|
||||||
readonly C: E1;
|
readonly C: E1.C;
|
||||||
>C : Symbol(C, Decl(enumBasics.ts, 14, 19))
|
>C : Symbol(C, Decl(enumBasics.ts, 14, 21))
|
||||||
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
>E1 : Symbol(E1, Decl(enumBasics.ts, 0, 0))
|
||||||
|
>C : Symbol(E1.C, Decl(enumBasics.ts, 3, 6))
|
||||||
|
|
||||||
readonly [n: number]: string;
|
readonly [n: number]: string;
|
||||||
>n : Symbol(n, Decl(enumBasics.ts, 16, 14))
|
>n : Symbol(n, Decl(enumBasics.ts, 16, 14))
|
||||||
|
|
|
@ -4,21 +4,21 @@ enum E1 {
|
||||||
>E1 : E1
|
>E1 : E1
|
||||||
|
|
||||||
A,
|
A,
|
||||||
>A : E1
|
>A : E1.A
|
||||||
|
|
||||||
B,
|
B,
|
||||||
>B : E1
|
>B : E1.B
|
||||||
|
|
||||||
C
|
C
|
||||||
>C : E1
|
>C : E1.C
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum type is a subtype of Number
|
// Enum type is a subtype of Number
|
||||||
var x: number = E1.A;
|
var x: number = E1.A;
|
||||||
>x : number
|
>x : number
|
||||||
>E1.A : E1
|
>E1.A : E1.A
|
||||||
>E1 : typeof E1
|
>E1 : typeof E1
|
||||||
>A : E1
|
>A : E1.A
|
||||||
|
|
||||||
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
||||||
var e = E1;
|
var e = E1;
|
||||||
|
@ -28,17 +28,20 @@ var e = E1;
|
||||||
var e: {
|
var e: {
|
||||||
>e : typeof E1
|
>e : typeof E1
|
||||||
|
|
||||||
readonly A: E1;
|
readonly A: E1.A;
|
||||||
>A : E1
|
>A : E1.A
|
||||||
>E1 : E1
|
>E1 : any
|
||||||
|
>A : E1.A
|
||||||
|
|
||||||
readonly B: E1;
|
readonly B: E1.B;
|
||||||
>B : E1
|
>B : E1.B
|
||||||
>E1 : E1
|
>E1 : any
|
||||||
|
>B : E1.B
|
||||||
|
|
||||||
readonly C: E1;
|
readonly C: E1.C;
|
||||||
>C : E1
|
>C : E1.C
|
||||||
>E1 : E1
|
>E1 : any
|
||||||
|
>C : E1.C
|
||||||
|
|
||||||
readonly [n: number]: string;
|
readonly [n: number]: string;
|
||||||
>n : number
|
>n : number
|
||||||
|
@ -53,9 +56,9 @@ var s = E1[e.A];
|
||||||
>s : string
|
>s : string
|
||||||
>E1[e.A] : string
|
>E1[e.A] : string
|
||||||
>E1 : typeof E1
|
>E1 : typeof E1
|
||||||
>e.A : E1
|
>e.A : E1.A
|
||||||
>e : typeof E1
|
>e : typeof E1
|
||||||
>A : E1
|
>A : E1.A
|
||||||
|
|
||||||
var s: string;
|
var s: string;
|
||||||
>s : string
|
>s : string
|
||||||
|
@ -66,12 +69,12 @@ enum E2 {
|
||||||
>E2 : E2
|
>E2 : E2
|
||||||
|
|
||||||
A = 1, B = 2, C = 3
|
A = 1, B = 2, C = 3
|
||||||
>A : E2
|
>A : E2.A
|
||||||
>1 : number
|
>1 : 1
|
||||||
>B : E2
|
>B : E2.B
|
||||||
>2 : number
|
>2 : 2
|
||||||
>C : E2
|
>C : E2.C
|
||||||
>3 : number
|
>3 : 3
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum with only computed members
|
// Enum with only computed members
|
||||||
|
@ -81,15 +84,15 @@ enum E3 {
|
||||||
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
|
X = 'foo'.length, Y = 4 + 3, Z = +'foo'
|
||||||
>X : E3
|
>X : E3
|
||||||
>'foo'.length : number
|
>'foo'.length : number
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
>length : number
|
>length : number
|
||||||
>Y : E3
|
>Y : E3
|
||||||
>4 + 3 : number
|
>4 + 3 : number
|
||||||
>4 : number
|
>4 : 4
|
||||||
>3 : number
|
>3 : 3
|
||||||
>Z : E3
|
>Z : E3
|
||||||
>+'foo' : number
|
>+'foo' : number
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum with constant members followed by computed members
|
// Enum with constant members followed by computed members
|
||||||
|
@ -98,11 +101,11 @@ enum E4 {
|
||||||
|
|
||||||
X = 0, Y, Z = 'foo'.length
|
X = 0, Y, Z = 'foo'.length
|
||||||
>X : E4
|
>X : E4
|
||||||
>0 : number
|
>0 : 0
|
||||||
>Y : E4
|
>Y : E4
|
||||||
>Z : E4
|
>Z : E4
|
||||||
>'foo'.length : number
|
>'foo'.length : number
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
>length : number
|
>length : number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,28 +114,28 @@ enum E5 {
|
||||||
>E5 : E5
|
>E5 : E5
|
||||||
|
|
||||||
A,
|
A,
|
||||||
>A : E5
|
>A : E5.A
|
||||||
|
|
||||||
B = 3,
|
B = 3,
|
||||||
>B : E5
|
>B : E5.B
|
||||||
>3 : number
|
>3 : 3
|
||||||
|
|
||||||
C // 4
|
C // 4
|
||||||
>C : E5
|
>C : E5.C
|
||||||
}
|
}
|
||||||
|
|
||||||
enum E6 {
|
enum E6 {
|
||||||
>E6 : E6
|
>E6 : E6
|
||||||
|
|
||||||
A,
|
A,
|
||||||
>A : E6
|
>A : E6.A
|
||||||
|
|
||||||
B = 0,
|
B = 0,
|
||||||
>B : E6
|
>B : E6.A
|
||||||
>0 : number
|
>0 : 0
|
||||||
|
|
||||||
C // 1
|
C // 1
|
||||||
>C : E6
|
>C : E6.C
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum with computed member initializer of type 'any'
|
// Enum with computed member initializer of type 'any'
|
||||||
|
@ -142,8 +145,8 @@ enum E7 {
|
||||||
A = 'foo'['foo']
|
A = 'foo'['foo']
|
||||||
>A : E7
|
>A : E7
|
||||||
>'foo'['foo'] : any
|
>'foo'['foo'] : any
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enum with computed member initializer of type number
|
// Enum with computed member initializer of type number
|
||||||
|
@ -153,8 +156,8 @@ enum E8 {
|
||||||
B = 'foo'['foo']
|
B = 'foo'['foo']
|
||||||
>B : E8
|
>B : E8
|
||||||
>'foo'['foo'] : any
|
>'foo'['foo'] : any
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
>'foo' : string
|
>'foo' : "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
//Enum with computed member intializer of same enum type
|
//Enum with computed member intializer of same enum type
|
||||||
|
@ -198,8 +201,8 @@ var doNotPropagate = [
|
||||||
];
|
];
|
||||||
// Enum computed members are not propagated
|
// Enum computed members are not propagated
|
||||||
var doPropagate = [
|
var doPropagate = [
|
||||||
>doPropagate : (E5 | E6 | E9)[]
|
>doPropagate : (E9 | E6 | E5)[]
|
||||||
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E5 | E6 | E9)[]
|
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : (E9 | E6 | E5)[]
|
||||||
|
|
||||||
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
|
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
|
||||||
>E9.A : E9
|
>E9.A : E9
|
||||||
|
@ -208,24 +211,24 @@ var doPropagate = [
|
||||||
>E9.B : E9
|
>E9.B : E9
|
||||||
>E9 : typeof E9
|
>E9 : typeof E9
|
||||||
>B : E9
|
>B : E9
|
||||||
>E6.B : E6
|
>E6.B : E6.A
|
||||||
>E6 : typeof E6
|
>E6 : typeof E6
|
||||||
>B : E6
|
>B : E6.A
|
||||||
>E6.C : E6
|
>E6.C : E6.C
|
||||||
>E6 : typeof E6
|
>E6 : typeof E6
|
||||||
>C : E6
|
>C : E6.C
|
||||||
>E6.A : E6
|
>E6.A : E6.A
|
||||||
>E6 : typeof E6
|
>E6 : typeof E6
|
||||||
>A : E6
|
>A : E6.A
|
||||||
>E5.A : E5
|
>E5.A : E5.A
|
||||||
>E5 : typeof E5
|
>E5 : typeof E5
|
||||||
>A : E5
|
>A : E5.A
|
||||||
>E5.B : E5
|
>E5.B : E5.B
|
||||||
>E5 : typeof E5
|
>E5 : typeof E5
|
||||||
>B : E5
|
>B : E5.B
|
||||||
>E5.C : E5
|
>E5.C : E5.C
|
||||||
>E5 : typeof E5
|
>E5 : typeof E5
|
||||||
>C : E5
|
>C : E5.C
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
218
tests/baselines/reference/enumClassification.js
Normal file
218
tests/baselines/reference/enumClassification.js
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
//// [enumClassification.ts]
|
||||||
|
// An enum type where each member has no initializer or an initializer that specififes
|
||||||
|
// a numeric literal, a string literal, or a single identifier naming another member in
|
||||||
|
// the enum type is classified as a literal enum type. An enum type that doesn't adhere
|
||||||
|
// to this pattern is classified as a numeric enum type.
|
||||||
|
|
||||||
|
// Examples of literal enum types
|
||||||
|
|
||||||
|
enum E01 {
|
||||||
|
A
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E02 {
|
||||||
|
A = 123
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E03 {
|
||||||
|
A = "hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E04 {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E05 {
|
||||||
|
A,
|
||||||
|
B = 10,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E06 {
|
||||||
|
A = "one",
|
||||||
|
B = "two",
|
||||||
|
C = "three"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E07 {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
C = "hi",
|
||||||
|
D = 10,
|
||||||
|
E,
|
||||||
|
F = "bye"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E08 {
|
||||||
|
A = 10,
|
||||||
|
B = "hello",
|
||||||
|
C = A,
|
||||||
|
D = B,
|
||||||
|
E = C,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with only constant members
|
||||||
|
|
||||||
|
enum E10 {}
|
||||||
|
|
||||||
|
enum E11 {
|
||||||
|
A = +0,
|
||||||
|
B,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E12 {
|
||||||
|
A = 1 << 0,
|
||||||
|
B = 1 << 1,
|
||||||
|
C = 1 << 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with constant and computed members
|
||||||
|
|
||||||
|
enum E20 {
|
||||||
|
A = "foo".length,
|
||||||
|
B = A + 1,
|
||||||
|
C = +"123",
|
||||||
|
D = Math.sin(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// [enumClassification.js]
|
||||||
|
// An enum type where each member has no initializer or an initializer that specififes
|
||||||
|
// a numeric literal, a string literal, or a single identifier naming another member in
|
||||||
|
// the enum type is classified as a literal enum type. An enum type that doesn't adhere
|
||||||
|
// to this pattern is classified as a numeric enum type.
|
||||||
|
// Examples of literal enum types
|
||||||
|
var E01;
|
||||||
|
(function (E01) {
|
||||||
|
E01[E01["A"] = 0] = "A";
|
||||||
|
})(E01 || (E01 = {}));
|
||||||
|
var E02;
|
||||||
|
(function (E02) {
|
||||||
|
E02[E02["A"] = 123] = "A";
|
||||||
|
})(E02 || (E02 = {}));
|
||||||
|
var E03;
|
||||||
|
(function (E03) {
|
||||||
|
E03["A"] = "hello";
|
||||||
|
})(E03 || (E03 = {}));
|
||||||
|
var E04;
|
||||||
|
(function (E04) {
|
||||||
|
E04[E04["A"] = 0] = "A";
|
||||||
|
E04[E04["B"] = 1] = "B";
|
||||||
|
E04[E04["C"] = 2] = "C";
|
||||||
|
})(E04 || (E04 = {}));
|
||||||
|
var E05;
|
||||||
|
(function (E05) {
|
||||||
|
E05[E05["A"] = 0] = "A";
|
||||||
|
E05[E05["B"] = 10] = "B";
|
||||||
|
E05[E05["C"] = 11] = "C";
|
||||||
|
})(E05 || (E05 = {}));
|
||||||
|
var E06;
|
||||||
|
(function (E06) {
|
||||||
|
E06["A"] = "one";
|
||||||
|
E06["B"] = "two";
|
||||||
|
E06["C"] = "three";
|
||||||
|
})(E06 || (E06 = {}));
|
||||||
|
var E07;
|
||||||
|
(function (E07) {
|
||||||
|
E07[E07["A"] = 0] = "A";
|
||||||
|
E07[E07["B"] = 1] = "B";
|
||||||
|
E07["C"] = "hi";
|
||||||
|
E07[E07["D"] = 10] = "D";
|
||||||
|
E07[E07["E"] = 11] = "E";
|
||||||
|
E07["F"] = "bye";
|
||||||
|
})(E07 || (E07 = {}));
|
||||||
|
var E08;
|
||||||
|
(function (E08) {
|
||||||
|
E08[E08["A"] = 10] = "A";
|
||||||
|
E08["B"] = "hello";
|
||||||
|
E08[E08["C"] = 10] = "C";
|
||||||
|
E08["D"] = "hello";
|
||||||
|
E08[E08["E"] = 10] = "E";
|
||||||
|
})(E08 || (E08 = {}));
|
||||||
|
// Examples of numeric enum types with only constant members
|
||||||
|
var E10;
|
||||||
|
(function (E10) {
|
||||||
|
})(E10 || (E10 = {}));
|
||||||
|
var E11;
|
||||||
|
(function (E11) {
|
||||||
|
E11[E11["A"] = 0] = "A";
|
||||||
|
E11[E11["B"] = 1] = "B";
|
||||||
|
E11[E11["C"] = 2] = "C";
|
||||||
|
})(E11 || (E11 = {}));
|
||||||
|
var E12;
|
||||||
|
(function (E12) {
|
||||||
|
E12[E12["A"] = 1] = "A";
|
||||||
|
E12[E12["B"] = 2] = "B";
|
||||||
|
E12[E12["C"] = 4] = "C";
|
||||||
|
})(E12 || (E12 = {}));
|
||||||
|
// Examples of numeric enum types with constant and computed members
|
||||||
|
var E20;
|
||||||
|
(function (E20) {
|
||||||
|
E20[E20["A"] = "foo".length] = "A";
|
||||||
|
E20[E20["B"] = E20.A + 1] = "B";
|
||||||
|
E20[E20["C"] = +"123"] = "C";
|
||||||
|
E20[E20["D"] = Math.sin(1)] = "D";
|
||||||
|
})(E20 || (E20 = {}));
|
||||||
|
|
||||||
|
|
||||||
|
//// [enumClassification.d.ts]
|
||||||
|
declare enum E01 {
|
||||||
|
A = 0,
|
||||||
|
}
|
||||||
|
declare enum E02 {
|
||||||
|
A = 123,
|
||||||
|
}
|
||||||
|
declare enum E03 {
|
||||||
|
A = "hello",
|
||||||
|
}
|
||||||
|
declare enum E04 {
|
||||||
|
A = 0,
|
||||||
|
B = 1,
|
||||||
|
C = 2,
|
||||||
|
}
|
||||||
|
declare enum E05 {
|
||||||
|
A = 0,
|
||||||
|
B = 10,
|
||||||
|
C = 11,
|
||||||
|
}
|
||||||
|
declare enum E06 {
|
||||||
|
A = "one",
|
||||||
|
B = "two",
|
||||||
|
C = "three",
|
||||||
|
}
|
||||||
|
declare enum E07 {
|
||||||
|
A = 0,
|
||||||
|
B = 1,
|
||||||
|
C = "hi",
|
||||||
|
D = 10,
|
||||||
|
E = 11,
|
||||||
|
F = "bye",
|
||||||
|
}
|
||||||
|
declare enum E08 {
|
||||||
|
A = 10,
|
||||||
|
B = "hello",
|
||||||
|
C = 10,
|
||||||
|
D = "hello",
|
||||||
|
E = 10,
|
||||||
|
}
|
||||||
|
declare enum E10 {
|
||||||
|
}
|
||||||
|
declare enum E11 {
|
||||||
|
A = 0,
|
||||||
|
B = 1,
|
||||||
|
C = 2,
|
||||||
|
}
|
||||||
|
declare enum E12 {
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
C = 4,
|
||||||
|
}
|
||||||
|
declare enum E20 {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
C,
|
||||||
|
D,
|
||||||
|
}
|
167
tests/baselines/reference/enumClassification.symbols
Normal file
167
tests/baselines/reference/enumClassification.symbols
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
=== tests/cases/conformance/enums/enumClassification.ts ===
|
||||||
|
// An enum type where each member has no initializer or an initializer that specififes
|
||||||
|
// a numeric literal, a string literal, or a single identifier naming another member in
|
||||||
|
// the enum type is classified as a literal enum type. An enum type that doesn't adhere
|
||||||
|
// to this pattern is classified as a numeric enum type.
|
||||||
|
|
||||||
|
// Examples of literal enum types
|
||||||
|
|
||||||
|
enum E01 {
|
||||||
|
>E01 : Symbol(E01, Decl(enumClassification.ts, 0, 0))
|
||||||
|
|
||||||
|
A
|
||||||
|
>A : Symbol(E01.A, Decl(enumClassification.ts, 7, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E02 {
|
||||||
|
>E02 : Symbol(E02, Decl(enumClassification.ts, 9, 1))
|
||||||
|
|
||||||
|
A = 123
|
||||||
|
>A : Symbol(E02.A, Decl(enumClassification.ts, 11, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E03 {
|
||||||
|
>E03 : Symbol(E03, Decl(enumClassification.ts, 13, 1))
|
||||||
|
|
||||||
|
A = "hello"
|
||||||
|
>A : Symbol(E03.A, Decl(enumClassification.ts, 15, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E04 {
|
||||||
|
>E04 : Symbol(E04, Decl(enumClassification.ts, 17, 1))
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : Symbol(E04.A, Decl(enumClassification.ts, 19, 10))
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : Symbol(E04.B, Decl(enumClassification.ts, 20, 6))
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : Symbol(E04.C, Decl(enumClassification.ts, 21, 6))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E05 {
|
||||||
|
>E05 : Symbol(E05, Decl(enumClassification.ts, 23, 1))
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : Symbol(E05.A, Decl(enumClassification.ts, 25, 10))
|
||||||
|
|
||||||
|
B = 10,
|
||||||
|
>B : Symbol(E05.B, Decl(enumClassification.ts, 26, 6))
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : Symbol(E05.C, Decl(enumClassification.ts, 27, 11))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E06 {
|
||||||
|
>E06 : Symbol(E06, Decl(enumClassification.ts, 29, 1))
|
||||||
|
|
||||||
|
A = "one",
|
||||||
|
>A : Symbol(E06.A, Decl(enumClassification.ts, 31, 10))
|
||||||
|
|
||||||
|
B = "two",
|
||||||
|
>B : Symbol(E06.B, Decl(enumClassification.ts, 32, 14))
|
||||||
|
|
||||||
|
C = "three"
|
||||||
|
>C : Symbol(E06.C, Decl(enumClassification.ts, 33, 14))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E07 {
|
||||||
|
>E07 : Symbol(E07, Decl(enumClassification.ts, 35, 1))
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : Symbol(E07.A, Decl(enumClassification.ts, 37, 10))
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : Symbol(E07.B, Decl(enumClassification.ts, 38, 6))
|
||||||
|
|
||||||
|
C = "hi",
|
||||||
|
>C : Symbol(E07.C, Decl(enumClassification.ts, 39, 6))
|
||||||
|
|
||||||
|
D = 10,
|
||||||
|
>D : Symbol(E07.D, Decl(enumClassification.ts, 40, 13))
|
||||||
|
|
||||||
|
E,
|
||||||
|
>E : Symbol(E07.E, Decl(enumClassification.ts, 41, 11))
|
||||||
|
|
||||||
|
F = "bye"
|
||||||
|
>F : Symbol(E07.F, Decl(enumClassification.ts, 42, 6))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E08 {
|
||||||
|
>E08 : Symbol(E08, Decl(enumClassification.ts, 44, 1))
|
||||||
|
|
||||||
|
A = 10,
|
||||||
|
>A : Symbol(E08.A, Decl(enumClassification.ts, 46, 10))
|
||||||
|
|
||||||
|
B = "hello",
|
||||||
|
>B : Symbol(E08.B, Decl(enumClassification.ts, 47, 11))
|
||||||
|
|
||||||
|
C = A,
|
||||||
|
>C : Symbol(E08.C, Decl(enumClassification.ts, 48, 16))
|
||||||
|
>A : Symbol(E08.A, Decl(enumClassification.ts, 46, 10))
|
||||||
|
|
||||||
|
D = B,
|
||||||
|
>D : Symbol(E08.D, Decl(enumClassification.ts, 49, 10))
|
||||||
|
>B : Symbol(E08.B, Decl(enumClassification.ts, 47, 11))
|
||||||
|
|
||||||
|
E = C,
|
||||||
|
>E : Symbol(E08.E, Decl(enumClassification.ts, 50, 10))
|
||||||
|
>C : Symbol(E08.C, Decl(enumClassification.ts, 48, 16))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with only constant members
|
||||||
|
|
||||||
|
enum E10 {}
|
||||||
|
>E10 : Symbol(E10, Decl(enumClassification.ts, 52, 1))
|
||||||
|
|
||||||
|
enum E11 {
|
||||||
|
>E11 : Symbol(E11, Decl(enumClassification.ts, 56, 11))
|
||||||
|
|
||||||
|
A = +0,
|
||||||
|
>A : Symbol(E11.A, Decl(enumClassification.ts, 58, 10))
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : Symbol(E11.B, Decl(enumClassification.ts, 59, 11))
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : Symbol(E11.C, Decl(enumClassification.ts, 60, 6))
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E12 {
|
||||||
|
>E12 : Symbol(E12, Decl(enumClassification.ts, 62, 1))
|
||||||
|
|
||||||
|
A = 1 << 0,
|
||||||
|
>A : Symbol(E12.A, Decl(enumClassification.ts, 64, 10))
|
||||||
|
|
||||||
|
B = 1 << 1,
|
||||||
|
>B : Symbol(E12.B, Decl(enumClassification.ts, 65, 15))
|
||||||
|
|
||||||
|
C = 1 << 2
|
||||||
|
>C : Symbol(E12.C, Decl(enumClassification.ts, 66, 15))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with constant and computed members
|
||||||
|
|
||||||
|
enum E20 {
|
||||||
|
>E20 : Symbol(E20, Decl(enumClassification.ts, 68, 1))
|
||||||
|
|
||||||
|
A = "foo".length,
|
||||||
|
>A : Symbol(E20.A, Decl(enumClassification.ts, 72, 10))
|
||||||
|
>"foo".length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||||
|
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||||
|
|
||||||
|
B = A + 1,
|
||||||
|
>B : Symbol(E20.B, Decl(enumClassification.ts, 73, 21))
|
||||||
|
>A : Symbol(E20.A, Decl(enumClassification.ts, 72, 10))
|
||||||
|
|
||||||
|
C = +"123",
|
||||||
|
>C : Symbol(E20.C, Decl(enumClassification.ts, 74, 14))
|
||||||
|
|
||||||
|
D = Math.sin(1)
|
||||||
|
>D : Symbol(E20.D, Decl(enumClassification.ts, 75, 15))
|
||||||
|
>Math.sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
|
||||||
|
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||||
|
>sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
|
||||||
|
}
|
||||||
|
|
196
tests/baselines/reference/enumClassification.types
Normal file
196
tests/baselines/reference/enumClassification.types
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
=== tests/cases/conformance/enums/enumClassification.ts ===
|
||||||
|
// An enum type where each member has no initializer or an initializer that specififes
|
||||||
|
// a numeric literal, a string literal, or a single identifier naming another member in
|
||||||
|
// the enum type is classified as a literal enum type. An enum type that doesn't adhere
|
||||||
|
// to this pattern is classified as a numeric enum type.
|
||||||
|
|
||||||
|
// Examples of literal enum types
|
||||||
|
|
||||||
|
enum E01 {
|
||||||
|
>E01 : E01
|
||||||
|
|
||||||
|
A
|
||||||
|
>A : E01
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E02 {
|
||||||
|
>E02 : E02
|
||||||
|
|
||||||
|
A = 123
|
||||||
|
>A : E02
|
||||||
|
>123 : 123
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E03 {
|
||||||
|
>E03 : E03
|
||||||
|
|
||||||
|
A = "hello"
|
||||||
|
>A : E03
|
||||||
|
>"hello" : "hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E04 {
|
||||||
|
>E04 : E04
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : E04.A
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : E04.B
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : E04.C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E05 {
|
||||||
|
>E05 : E05
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : E05.A
|
||||||
|
|
||||||
|
B = 10,
|
||||||
|
>B : E05.B
|
||||||
|
>10 : 10
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : E05.C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E06 {
|
||||||
|
>E06 : E06
|
||||||
|
|
||||||
|
A = "one",
|
||||||
|
>A : E06.A
|
||||||
|
>"one" : "one"
|
||||||
|
|
||||||
|
B = "two",
|
||||||
|
>B : E06.B
|
||||||
|
>"two" : "two"
|
||||||
|
|
||||||
|
C = "three"
|
||||||
|
>C : E06.C
|
||||||
|
>"three" : "three"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E07 {
|
||||||
|
>E07 : E07
|
||||||
|
|
||||||
|
A,
|
||||||
|
>A : E07.A
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : E07.B
|
||||||
|
|
||||||
|
C = "hi",
|
||||||
|
>C : E07.C
|
||||||
|
>"hi" : "hi"
|
||||||
|
|
||||||
|
D = 10,
|
||||||
|
>D : E07.D
|
||||||
|
>10 : 10
|
||||||
|
|
||||||
|
E,
|
||||||
|
>E : E07.E
|
||||||
|
|
||||||
|
F = "bye"
|
||||||
|
>F : E07.F
|
||||||
|
>"bye" : "bye"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E08 {
|
||||||
|
>E08 : E08
|
||||||
|
|
||||||
|
A = 10,
|
||||||
|
>A : E08.A
|
||||||
|
>10 : 10
|
||||||
|
|
||||||
|
B = "hello",
|
||||||
|
>B : E08.B
|
||||||
|
>"hello" : "hello"
|
||||||
|
|
||||||
|
C = A,
|
||||||
|
>C : E08.A
|
||||||
|
>A : E08.A
|
||||||
|
|
||||||
|
D = B,
|
||||||
|
>D : E08.B
|
||||||
|
>B : E08.B
|
||||||
|
|
||||||
|
E = C,
|
||||||
|
>E : E08.A
|
||||||
|
>C : E08.A
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with only constant members
|
||||||
|
|
||||||
|
enum E10 {}
|
||||||
|
>E10 : E10
|
||||||
|
|
||||||
|
enum E11 {
|
||||||
|
>E11 : E11
|
||||||
|
|
||||||
|
A = +0,
|
||||||
|
>A : E11
|
||||||
|
>+0 : number
|
||||||
|
>0 : 0
|
||||||
|
|
||||||
|
B,
|
||||||
|
>B : E11
|
||||||
|
|
||||||
|
C
|
||||||
|
>C : E11
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E12 {
|
||||||
|
>E12 : E12
|
||||||
|
|
||||||
|
A = 1 << 0,
|
||||||
|
>A : E12
|
||||||
|
>1 << 0 : number
|
||||||
|
>1 : 1
|
||||||
|
>0 : 0
|
||||||
|
|
||||||
|
B = 1 << 1,
|
||||||
|
>B : E12
|
||||||
|
>1 << 1 : number
|
||||||
|
>1 : 1
|
||||||
|
>1 : 1
|
||||||
|
|
||||||
|
C = 1 << 2
|
||||||
|
>C : E12
|
||||||
|
>1 << 2 : number
|
||||||
|
>1 : 1
|
||||||
|
>2 : 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with constant and computed members
|
||||||
|
|
||||||
|
enum E20 {
|
||||||
|
>E20 : E20
|
||||||
|
|
||||||
|
A = "foo".length,
|
||||||
|
>A : E20
|
||||||
|
>"foo".length : number
|
||||||
|
>"foo" : "foo"
|
||||||
|
>length : number
|
||||||
|
|
||||||
|
B = A + 1,
|
||||||
|
>B : E20
|
||||||
|
>A + 1 : number
|
||||||
|
>A : E20
|
||||||
|
>1 : 1
|
||||||
|
|
||||||
|
C = +"123",
|
||||||
|
>C : E20
|
||||||
|
>+"123" : number
|
||||||
|
>"123" : "123"
|
||||||
|
|
||||||
|
D = Math.sin(1)
|
||||||
|
>D : E20
|
||||||
|
>Math.sin(1) : number
|
||||||
|
>Math.sin : (x: number) => number
|
||||||
|
>Math : Math
|
||||||
|
>sin : (x: number) => number
|
||||||
|
>1 : 1
|
||||||
|
}
|
||||||
|
|
|
@ -3,13 +3,17 @@ tests/cases/conformance/enums/enumErrors.ts(3,6): error TS2431: Enum name cannot
|
||||||
tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string'.
|
tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean'.
|
tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(9,9): error TS2322: Type 'Number' is not assignable to type 'E5'.
|
tests/cases/conformance/enums/enumErrors.ts(9,9): error TS2322: Type 'Number' is not assignable to type 'E5'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type '""' is not assignable to type 'E11'.
|
tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type 'true' is not assignable to type 'E11'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(27,9): error TS2322: Type 'Date' is not assignable to type 'E11'.
|
tests/cases/conformance/enums/enumErrors.ts(27,9): error TS2322: Type 'Date' is not assignable to type 'E11'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(28,9): error TS2304: Cannot find name 'window'.
|
tests/cases/conformance/enums/enumErrors.ts(28,9): error TS2304: Cannot find name 'window'.
|
||||||
tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is not assignable to type 'E11'.
|
tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is not assignable to type 'E11'.
|
||||||
|
tests/cases/conformance/enums/enumErrors.ts(35,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
tests/cases/conformance/enums/enumErrors.ts(36,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
tests/cases/conformance/enums/enumErrors.ts(37,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
tests/cases/conformance/enums/enumErrors.ts(38,9): error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/enums/enumErrors.ts (9 errors) ====
|
==== tests/cases/conformance/enums/enumErrors.ts (13 errors) ====
|
||||||
// Enum named with PredefinedTypes
|
// Enum named with PredefinedTypes
|
||||||
enum any { }
|
enum any { }
|
||||||
~~~
|
~~~
|
||||||
|
@ -45,9 +49,9 @@ tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is no
|
||||||
|
|
||||||
// Enum with computed member intializer of other types
|
// Enum with computed member intializer of other types
|
||||||
enum E11 {
|
enum E11 {
|
||||||
A = '',
|
A = true,
|
||||||
~~
|
~~~~
|
||||||
!!! error TS2322: Type '""' is not assignable to type 'E11'.
|
!!! error TS2322: Type 'true' is not assignable to type 'E11'.
|
||||||
B = new Date(),
|
B = new Date(),
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
!!! error TS2322: Type 'Date' is not assignable to type 'E11'.
|
!!! error TS2322: Type 'Date' is not assignable to type 'E11'.
|
||||||
|
@ -58,4 +62,21 @@ tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is no
|
||||||
~~
|
~~
|
||||||
!!! error TS2322: Type '{}' is not assignable to type 'E11'.
|
!!! error TS2322: Type '{}' is not assignable to type 'E11'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enum with string valued member and computed member initializers
|
||||||
|
enum E12 {
|
||||||
|
A = '',
|
||||||
|
B = new Date(),
|
||||||
|
~~~~~~~~~~
|
||||||
|
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
C = window,
|
||||||
|
~~~~~~
|
||||||
|
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
D = {},
|
||||||
|
~~
|
||||||
|
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
E = 1 + 1,
|
||||||
|
~~~~~
|
||||||
|
!!! error TS2553: Computed values are not permitted in an enum with string valued members.
|
||||||
|
}
|
||||||
|
|
|
@ -24,11 +24,20 @@ enum E10 {
|
||||||
|
|
||||||
// Enum with computed member intializer of other types
|
// Enum with computed member intializer of other types
|
||||||
enum E11 {
|
enum E11 {
|
||||||
A = '',
|
A = true,
|
||||||
B = new Date(),
|
B = new Date(),
|
||||||
C = window,
|
C = window,
|
||||||
D = {}
|
D = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enum with string valued member and computed member initializers
|
||||||
|
enum E12 {
|
||||||
|
A = '',
|
||||||
|
B = new Date(),
|
||||||
|
C = window,
|
||||||
|
D = {},
|
||||||
|
E = 1 + 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// [enumErrors.js]
|
//// [enumErrors.js]
|
||||||
|
@ -65,8 +74,17 @@ var E10;
|
||||||
// Enum with computed member intializer of other types
|
// Enum with computed member intializer of other types
|
||||||
var E11;
|
var E11;
|
||||||
(function (E11) {
|
(function (E11) {
|
||||||
E11[E11["A"] = ''] = "A";
|
E11[E11["A"] = true] = "A";
|
||||||
E11[E11["B"] = new Date()] = "B";
|
E11[E11["B"] = new Date()] = "B";
|
||||||
E11[E11["C"] = window] = "C";
|
E11[E11["C"] = window] = "C";
|
||||||
E11[E11["D"] = {}] = "D";
|
E11[E11["D"] = {}] = "D";
|
||||||
})(E11 || (E11 = {}));
|
})(E11 || (E11 = {}));
|
||||||
|
// Enum with string valued member and computed member initializers
|
||||||
|
var E12;
|
||||||
|
(function (E12) {
|
||||||
|
E12["A"] = "";
|
||||||
|
E12[E12["B"] = 0] = "B";
|
||||||
|
E12[E12["C"] = 0] = "C";
|
||||||
|
E12[E12["D"] = 0] = "D";
|
||||||
|
E12[E12["E"] = 0] = "E";
|
||||||
|
})(E12 || (E12 = {}));
|
||||||
|
|
|
@ -220,7 +220,7 @@ class testClass {
|
||||||
>testClass : testClass
|
>testClass : testClass
|
||||||
|
|
||||||
public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) {
|
public func(arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) {
|
||||||
>func : (arg1: number, arg\u0032: string, arg\u0033: boolean, arg4: number) => void
|
>func : (arg1: number, arg2: string, arg3: boolean, arg4: number) => void
|
||||||
>arg1 : number
|
>arg1 : number
|
||||||
>arg\u0032 : string
|
>arg\u0032 : string
|
||||||
>arg\u0033 : boolean
|
>arg\u0033 : boolean
|
||||||
|
|
|
@ -19,11 +19,11 @@ var E1;
|
||||||
(function (E1) {
|
(function (E1) {
|
||||||
// illegal case
|
// illegal case
|
||||||
// forward reference to the element of the same enum
|
// forward reference to the element of the same enum
|
||||||
E1[E1["X"] = E1.Y] = "X";
|
E1[E1["X"] = 0] = "X";
|
||||||
E1[E1["X1"] = E1["Y"]] = "X1";
|
E1[E1["X1"] = 0] = "X1";
|
||||||
// forward reference to the element of the same enum
|
// forward reference to the element of the same enum
|
||||||
E1[E1["Y"] = E1.Z] = "Y";
|
E1[E1["Y"] = 0] = "Y";
|
||||||
E1[E1["Y1"] = E1["Z"]] = "Y1";
|
E1[E1["Y1"] = 0] = "Y1";
|
||||||
})(E1 || (E1 = {}));
|
})(E1 || (E1 = {}));
|
||||||
(function (E1) {
|
(function (E1) {
|
||||||
E1[E1["Z"] = 4] = "Z";
|
E1[E1["Z"] = 4] = "Z";
|
||||||
|
|
|
@ -290,7 +290,7 @@ function f3() {
|
||||||
>c2 : 1 | "two"
|
>c2 : 1 | "two"
|
||||||
|
|
||||||
let x3 = c3;
|
let x3 = c3;
|
||||||
>x3 : number | boolean | E
|
>x3 : number | boolean
|
||||||
>c3 : true | E.A | 123
|
>c3 : true | E.A | 123
|
||||||
|
|
||||||
let x4 = c4;
|
let x4 = c4;
|
||||||
|
|
|
@ -365,7 +365,7 @@ var rf5 = a5 && a6;
|
||||||
|
|
||||||
var rf6 = a6 && a6;
|
var rf6 = a6 && a6;
|
||||||
>rf6 : E
|
>rf6 : E
|
||||||
>a6 && a6 : E.b | E.c
|
>a6 && a6 : E
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a6 : E.b | E.c
|
>a6 : E.b | E.c
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ var rb5 = a5 || a2; // void || boolean is void | boolean
|
||||||
|
|
||||||
var rb6 = a6 || a2; // enum || boolean is E | boolean
|
var rb6 = a6 || a2; // enum || boolean is E | boolean
|
||||||
>rb6 : boolean | E
|
>rb6 : boolean | E
|
||||||
>a6 || a2 : boolean | E
|
>a6 || a2 : boolean | E.b | E.c
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a2 : boolean
|
>a2 : boolean
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ var rd5 = a5 || a4; // void || string is void | string
|
||||||
|
|
||||||
var rd6 = a6 || a4; // enum || string is enum | string
|
var rd6 = a6 || a4; // enum || string is enum | string
|
||||||
>rd6 : string | E
|
>rd6 : string | E
|
||||||
>a6 || a4 : string | E
|
>a6 || a4 : string | E.b | E.c
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a4 : string
|
>a4 : string
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ var re5 = a5 || a5; // void || void is void
|
||||||
|
|
||||||
var re6 = a6 || a5; // enum || void is enum | void
|
var re6 = a6 || a5; // enum || void is enum | void
|
||||||
>re6 : void | E
|
>re6 : void | E
|
||||||
>a6 || a5 : void | E
|
>a6 || a5 : void | E.b | E.c
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a5 : void
|
>a5 : void
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ var rh5 = a5 || a7; // void || object is void | object
|
||||||
|
|
||||||
var rh6 = a6 || a7; // enum || object is enum | object
|
var rh6 = a6 || a7; // enum || object is enum | object
|
||||||
>rh6 : E | { a: string; }
|
>rh6 : E | { a: string; }
|
||||||
>a6 || a7 : E | { a: string; }
|
>a6 || a7 : E.b | E.c | { a: string; }
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a7 : { a: string; }
|
>a7 : { a: string; }
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ var ri5 = a5 || a8; // void || array is void | array
|
||||||
|
|
||||||
var ri6 = a6 || a8; // enum || array is enum | array
|
var ri6 = a6 || a8; // enum || array is enum | array
|
||||||
>ri6 : E | string[]
|
>ri6 : E | string[]
|
||||||
>a6 || a8 : E | string[]
|
>a6 || a8 : E.b | E.c | string[]
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>a8 : string[]
|
>a8 : string[]
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ var rj5 = a5 || null; // void || null is void
|
||||||
|
|
||||||
var rj6 = a6 || null; // enum || null is E
|
var rj6 = a6 || null; // enum || null is E
|
||||||
>rj6 : E
|
>rj6 : E
|
||||||
>a6 || null : E
|
>a6 || null : E.b | E.c
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>null : null
|
>null : null
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ var rf5 = a5 || undefined; // void || undefined is void
|
||||||
|
|
||||||
var rf6 = a6 || undefined; // enum || undefined is E
|
var rf6 = a6 || undefined; // enum || undefined is E
|
||||||
>rf6 : E
|
>rf6 : E
|
||||||
>a6 || undefined : E
|
>a6 || undefined : E.b | E.c
|
||||||
>a6 : E
|
>a6 : E
|
||||||
>undefined : undefined
|
>undefined : undefined
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,6 @@ class D {
|
||||||
>PropDeco : (target: Object, propKey: string | symbol) => void
|
>PropDeco : (target: Object, propKey: string | symbol) => void
|
||||||
|
|
||||||
d: E | number;
|
d: E | number;
|
||||||
>d : number | E
|
>d : number
|
||||||
>E : E
|
>E : E
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
tests/cases/compiler/objectLiteralFreshnessWithSpread.ts(2,35): error TS2322: Type '{ z: number; b: number; extra: number; a: number; }' is not assignable to type '{ a: any; b: any; }'.
|
||||||
|
Object literal may only specify known properties, and 'z' does not exist in type '{ a: any; b: any; }'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/objectLiteralFreshnessWithSpread.ts (1 errors) ====
|
||||||
|
let x = { b: 1, extra: 2 }
|
||||||
|
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra'
|
||||||
|
~~~~
|
||||||
|
!!! error TS2322: Type '{ z: number; b: number; extra: number; a: number; }' is not assignable to type '{ a: any; b: any; }'.
|
||||||
|
!!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ a: any; b: any; }'.
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
//// [objectLiteralFreshnessWithSpread.ts]
|
||||||
|
let x = { b: 1, extra: 2 }
|
||||||
|
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra'
|
||||||
|
|
||||||
|
|
||||||
|
//// [objectLiteralFreshnessWithSpread.js]
|
||||||
|
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||||
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||||
|
s = arguments[i];
|
||||||
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||||
|
t[p] = s[p];
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
var x = { b: 1, extra: 2 };
|
||||||
|
var xx = __assign({ a: 1 }, x, { z: 3 }); // error for 'z', no error for 'extra'
|
178
tests/baselines/reference/stringEnumLiteralTypes1.js
Normal file
178
tests/baselines/reference/stringEnumLiteralTypes1.js
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
//// [stringEnumLiteralTypes1.ts]
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
var a: YesNo;
|
||||||
|
var a: NoYes;
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [stringEnumLiteralTypes1.js]
|
||||||
|
;
|
||||||
|
function f1() {
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
function f2(a, b, c) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
function f3(a, b) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
function f5(a, b, c) {
|
||||||
|
var z1 = g("yes" /* Yes */);
|
||||||
|
var z2 = g("no" /* No */);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
function assertNever(x) {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
function f10(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "yes" /* Yes */: return "true";
|
||||||
|
case "no" /* No */: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f11(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "yes" /* Yes */: return "true";
|
||||||
|
case "no" /* No */: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
function f12(x) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f13(x) {
|
||||||
|
if (x === "yes" /* Yes */) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f20(x) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case "yes" /* Yes */: return x.a;
|
||||||
|
case "no" /* No */: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f21(x) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case "yes" /* Yes */: return x.a;
|
||||||
|
case "no" /* No */: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
353
tests/baselines/reference/stringEnumLiteralTypes1.symbols
Normal file
353
tests/baselines/reference/stringEnumLiteralTypes1.symbols
Normal file
|
@ -0,0 +1,353 @@
|
||||||
|
=== tests/cases/conformance/types/literal/stringEnumLiteralTypes1.ts ===
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Unknown : Symbol(Choice.Unknown, Decl(stringEnumLiteralTypes1.ts, 0, 19))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
>NoYes : Symbol(NoYes, Decl(stringEnumLiteralTypes1.ts, 2, 36))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes1.ts, 3, 36))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Unknown : Symbol(Choice.Unknown, Decl(stringEnumLiteralTypes1.ts, 0, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
>f1 : Symbol(f1, Decl(stringEnumLiteralTypes1.ts, 4, 60))
|
||||||
|
|
||||||
|
var a: YesNo;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 7, 7), Decl(stringEnumLiteralTypes1.ts, 8, 7), Decl(stringEnumLiteralTypes1.ts, 9, 7), Decl(stringEnumLiteralTypes1.ts, 10, 7))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
|
||||||
|
var a: NoYes;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 7, 7), Decl(stringEnumLiteralTypes1.ts, 8, 7), Decl(stringEnumLiteralTypes1.ts, 9, 7), Decl(stringEnumLiteralTypes1.ts, 10, 7))
|
||||||
|
>NoYes : Symbol(NoYes, Decl(stringEnumLiteralTypes1.ts, 2, 36))
|
||||||
|
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 7, 7), Decl(stringEnumLiteralTypes1.ts, 8, 7), Decl(stringEnumLiteralTypes1.ts, 9, 7), Decl(stringEnumLiteralTypes1.ts, 10, 7))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 7, 7), Decl(stringEnumLiteralTypes1.ts, 8, 7), Decl(stringEnumLiteralTypes1.ts, 9, 7), Decl(stringEnumLiteralTypes1.ts, 10, 7))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f2 : Symbol(f2, Decl(stringEnumLiteralTypes1.ts, 11, 1))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 13, 12))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 13, 21))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes1.ts, 3, 36))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes1.ts, 13, 38))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
|
||||||
|
b = a;
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 13, 21))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 13, 12))
|
||||||
|
|
||||||
|
c = a;
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes1.ts, 13, 38))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 13, 12))
|
||||||
|
|
||||||
|
c = b;
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes1.ts, 13, 38))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 13, 21))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
>f3 : Symbol(f3, Decl(stringEnumLiteralTypes1.ts, 17, 1))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
|
||||||
|
var x = a + b;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 20, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a == b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a != b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a === b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a !== b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a > b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a < b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a >= b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a <= b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = !b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes1.ts, 21, 7), Decl(stringEnumLiteralTypes1.ts, 22, 7), Decl(stringEnumLiteralTypes1.ts, 23, 7), Decl(stringEnumLiteralTypes1.ts, 24, 7), Decl(stringEnumLiteralTypes1.ts, 25, 7), Decl(stringEnumLiteralTypes1.ts, 26, 7), Decl(stringEnumLiteralTypes1.ts, 27, 7), Decl(stringEnumLiteralTypes1.ts, 28, 7), Decl(stringEnumLiteralTypes1.ts, 29, 7))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 19, 26))
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 32, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 33, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 34, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f5 : Symbol(f5, Decl(stringEnumLiteralTypes1.ts, 34, 38))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 36, 12))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 36, 21))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes1.ts, 3, 36))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes1.ts, 36, 38))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
>z1 : Symbol(z1, Decl(stringEnumLiteralTypes1.ts, 37, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
>z2 : Symbol(z2, Decl(stringEnumLiteralTypes1.ts, 38, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
|
||||||
|
var z3 = g(a);
|
||||||
|
>z3 : Symbol(z3, Decl(stringEnumLiteralTypes1.ts, 39, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 36, 12))
|
||||||
|
|
||||||
|
var z4 = g(b);
|
||||||
|
>z4 : Symbol(z4, Decl(stringEnumLiteralTypes1.ts, 40, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 36, 21))
|
||||||
|
|
||||||
|
var z5 = g(c);
|
||||||
|
>z5 : Symbol(z5, Decl(stringEnumLiteralTypes1.ts, 41, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes1.ts, 30, 1), Decl(stringEnumLiteralTypes1.ts, 32, 42), Decl(stringEnumLiteralTypes1.ts, 33, 42))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes1.ts, 36, 38))
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes1.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 44, 21))
|
||||||
|
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
>f10 : Symbol(f10, Decl(stringEnumLiteralTypes1.ts, 46, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 48, 13))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 48, 13))
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
>f11 : Symbol(f11, Decl(stringEnumLiteralTypes1.ts, 53, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 55, 13))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes1.ts, 0, 59))
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 55, 13))
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes1.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 55, 13))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
>f12 : Symbol(f12, Decl(stringEnumLiteralTypes1.ts, 61, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 63, 13))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes1.ts, 3, 36))
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 63, 13))
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 63, 13))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 63, 13))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
>f13 : Symbol(f13, Decl(stringEnumLiteralTypes1.ts, 70, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 72, 13))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes1.ts, 3, 36))
|
||||||
|
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 72, 13))
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 72, 13))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 72, 13))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes1.ts, 79, 1))
|
||||||
|
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 82, 5))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 82, 23))
|
||||||
|
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 83, 5))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 83, 22))
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
>f20 : Symbol(f20, Decl(stringEnumLiteralTypes1.ts, 83, 35))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 85, 13))
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes1.ts, 79, 1))
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 82, 5), Decl(stringEnumLiteralTypes1.ts, 83, 5))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 85, 13))
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 82, 5), Decl(stringEnumLiteralTypes1.ts, 83, 5))
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>x.a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 82, 23))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 85, 13))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 82, 23))
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>x.b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 83, 22))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 85, 13))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 83, 22))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
>f21 : Symbol(f21, Decl(stringEnumLiteralTypes1.ts, 90, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 92, 13))
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes1.ts, 79, 1))
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 82, 5), Decl(stringEnumLiteralTypes1.ts, 83, 5))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 92, 13))
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes1.ts, 82, 5), Decl(stringEnumLiteralTypes1.ts, 83, 5))
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes1.ts, 0, 33))
|
||||||
|
>x.a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 82, 23))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 92, 13))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes1.ts, 82, 23))
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes1.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes1.ts, 0, 46))
|
||||||
|
>x.b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 83, 22))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 92, 13))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes1.ts, 83, 22))
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes1.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes1.ts, 92, 13))
|
||||||
|
}
|
383
tests/baselines/reference/stringEnumLiteralTypes1.types
Normal file
383
tests/baselines/reference/stringEnumLiteralTypes1.types
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
=== tests/cases/conformance/types/literal/stringEnumLiteralTypes1.ts ===
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
>Choice : Choice
|
||||||
|
>Unknown : Choice.Unknown
|
||||||
|
>"" : ""
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"yes" : "yes"
|
||||||
|
>No : Choice.No
|
||||||
|
>"no" : "no"
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
>YesNo : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
>NoYes : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>Choice : any
|
||||||
|
>Unknown : Choice.Unknown
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
>f1 : () => void
|
||||||
|
|
||||||
|
var a: YesNo;
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
var a: NoYes;
|
||||||
|
>a : YesNo
|
||||||
|
>NoYes : YesNo
|
||||||
|
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
>a : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
>a : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f2 : (a: YesNo, b: Choice, c: Choice) => void
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>c : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
b = a;
|
||||||
|
>b = a : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
c = a;
|
||||||
|
>c = a : YesNo
|
||||||
|
>c : Choice
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
c = b;
|
||||||
|
>c = b : YesNo
|
||||||
|
>c : Choice
|
||||||
|
>b : YesNo
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
>f3 : (a: Choice.Yes, b: YesNo) => void
|
||||||
|
>a : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
var x = a + b;
|
||||||
|
>x : string
|
||||||
|
>a + b : string
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a == b;
|
||||||
|
>y : boolean
|
||||||
|
>a == b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a != b;
|
||||||
|
>y : boolean
|
||||||
|
>a != b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a === b;
|
||||||
|
>y : boolean
|
||||||
|
>a === b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a !== b;
|
||||||
|
>y : boolean
|
||||||
|
>a !== b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a > b;
|
||||||
|
>y : boolean
|
||||||
|
>a > b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a < b;
|
||||||
|
>y : boolean
|
||||||
|
>a < b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a >= b;
|
||||||
|
>y : boolean
|
||||||
|
>a >= b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a <= b;
|
||||||
|
>y : boolean
|
||||||
|
>a <= b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = !b;
|
||||||
|
>y : boolean
|
||||||
|
>!b : boolean
|
||||||
|
>b : YesNo
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f5 : (a: YesNo, b: Choice, c: Choice) => void
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>c : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
>z1 : string
|
||||||
|
>g(Choice.Yes) : string
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
>z2 : boolean
|
||||||
|
>g(Choice.No) : boolean
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
var z3 = g(a);
|
||||||
|
>z3 : number
|
||||||
|
>g(a) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
var z4 = g(b);
|
||||||
|
>z4 : number
|
||||||
|
>g(b) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>b : Choice
|
||||||
|
|
||||||
|
var z5 = g(c);
|
||||||
|
>z5 : number
|
||||||
|
>g(c) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>c : Choice
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
>new Error("Unexpected value") : Error
|
||||||
|
>Error : ErrorConstructor
|
||||||
|
>"Unexpected value" : "Unexpected value"
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
>f10 : (x: YesNo) => "true" | "false"
|
||||||
|
>x : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"true" : "true"
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>"false" : "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
>f11 : (x: YesNo) => "true" | "false"
|
||||||
|
>x : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"true" : "true"
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>"false" : "false"
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever(x) : never
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
>f12 : (x: Choice) => void
|
||||||
|
>x : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
>x : Choice
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : YesNo
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Choice
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
>f13 : (x: Choice) => void
|
||||||
|
>x : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
>x === Choice.Yes : boolean
|
||||||
|
>x : Choice
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Choice.Yes
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Choice.Unknown | Choice.No
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
>kind : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
>kind : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>b : string
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
>f20 : (x: Item) => string
|
||||||
|
>x : Item
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : YesNo
|
||||||
|
>x : Item
|
||||||
|
>kind : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>x.a : string
|
||||||
|
>x : { kind: Choice.Yes; a: string; }
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>x.b : string
|
||||||
|
>x : { kind: Choice.No; b: string; }
|
||||||
|
>b : string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
>f21 : (x: Item) => string
|
||||||
|
>x : Item
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : YesNo
|
||||||
|
>x : Item
|
||||||
|
>kind : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>x.a : string
|
||||||
|
>x : { kind: Choice.Yes; a: string; }
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>x.b : string
|
||||||
|
>x : { kind: Choice.No; b: string; }
|
||||||
|
>b : string
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever(x) : never
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
}
|
178
tests/baselines/reference/stringEnumLiteralTypes2.js
Normal file
178
tests/baselines/reference/stringEnumLiteralTypes2.js
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
//// [stringEnumLiteralTypes2.ts]
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
var a: YesNo;
|
||||||
|
var a: NoYes;
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [stringEnumLiteralTypes2.js]
|
||||||
|
;
|
||||||
|
function f1() {
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
function f2(a, b, c) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
function f3(a, b) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
function f5(a, b, c) {
|
||||||
|
var z1 = g("yes" /* Yes */);
|
||||||
|
var z2 = g("no" /* No */);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
function assertNever(x) {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
function f10(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "yes" /* Yes */: return "true";
|
||||||
|
case "no" /* No */: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f11(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "yes" /* Yes */: return "true";
|
||||||
|
case "no" /* No */: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
function f12(x) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f13(x) {
|
||||||
|
if (x === "yes" /* Yes */) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f20(x) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case "yes" /* Yes */: return x.a;
|
||||||
|
case "no" /* No */: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function f21(x) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case "yes" /* Yes */: return x.a;
|
||||||
|
case "no" /* No */: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
353
tests/baselines/reference/stringEnumLiteralTypes2.symbols
Normal file
353
tests/baselines/reference/stringEnumLiteralTypes2.symbols
Normal file
|
@ -0,0 +1,353 @@
|
||||||
|
=== tests/cases/conformance/types/literal/stringEnumLiteralTypes2.ts ===
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Unknown : Symbol(Choice.Unknown, Decl(stringEnumLiteralTypes2.ts, 0, 19))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
>NoYes : Symbol(NoYes, Decl(stringEnumLiteralTypes2.ts, 2, 36))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes2.ts, 3, 36))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Unknown : Symbol(Choice.Unknown, Decl(stringEnumLiteralTypes2.ts, 0, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
>f1 : Symbol(f1, Decl(stringEnumLiteralTypes2.ts, 4, 60))
|
||||||
|
|
||||||
|
var a: YesNo;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 7, 7), Decl(stringEnumLiteralTypes2.ts, 8, 7), Decl(stringEnumLiteralTypes2.ts, 9, 7), Decl(stringEnumLiteralTypes2.ts, 10, 7))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
|
||||||
|
var a: NoYes;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 7, 7), Decl(stringEnumLiteralTypes2.ts, 8, 7), Decl(stringEnumLiteralTypes2.ts, 9, 7), Decl(stringEnumLiteralTypes2.ts, 10, 7))
|
||||||
|
>NoYes : Symbol(NoYes, Decl(stringEnumLiteralTypes2.ts, 2, 36))
|
||||||
|
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 7, 7), Decl(stringEnumLiteralTypes2.ts, 8, 7), Decl(stringEnumLiteralTypes2.ts, 9, 7), Decl(stringEnumLiteralTypes2.ts, 10, 7))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 7, 7), Decl(stringEnumLiteralTypes2.ts, 8, 7), Decl(stringEnumLiteralTypes2.ts, 9, 7), Decl(stringEnumLiteralTypes2.ts, 10, 7))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f2 : Symbol(f2, Decl(stringEnumLiteralTypes2.ts, 11, 1))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 13, 12))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 13, 21))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes2.ts, 3, 36))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes2.ts, 13, 38))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
|
||||||
|
b = a;
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 13, 21))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 13, 12))
|
||||||
|
|
||||||
|
c = a;
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes2.ts, 13, 38))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 13, 12))
|
||||||
|
|
||||||
|
c = b;
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes2.ts, 13, 38))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 13, 21))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
>f3 : Symbol(f3, Decl(stringEnumLiteralTypes2.ts, 17, 1))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
|
||||||
|
var x = a + b;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 20, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a == b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a != b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a === b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a !== b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a > b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a < b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a >= b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = a <= b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 19, 12))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
|
||||||
|
var y = !b;
|
||||||
|
>y : Symbol(y, Decl(stringEnumLiteralTypes2.ts, 21, 7), Decl(stringEnumLiteralTypes2.ts, 22, 7), Decl(stringEnumLiteralTypes2.ts, 23, 7), Decl(stringEnumLiteralTypes2.ts, 24, 7), Decl(stringEnumLiteralTypes2.ts, 25, 7), Decl(stringEnumLiteralTypes2.ts, 26, 7), Decl(stringEnumLiteralTypes2.ts, 27, 7), Decl(stringEnumLiteralTypes2.ts, 28, 7), Decl(stringEnumLiteralTypes2.ts, 29, 7))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 19, 26))
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 32, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 33, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 34, 19))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f5 : Symbol(f5, Decl(stringEnumLiteralTypes2.ts, 34, 38))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 36, 12))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 36, 21))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes2.ts, 3, 36))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes2.ts, 36, 38))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
>z1 : Symbol(z1, Decl(stringEnumLiteralTypes2.ts, 37, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
>z2 : Symbol(z2, Decl(stringEnumLiteralTypes2.ts, 38, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
|
||||||
|
var z3 = g(a);
|
||||||
|
>z3 : Symbol(z3, Decl(stringEnumLiteralTypes2.ts, 39, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 36, 12))
|
||||||
|
|
||||||
|
var z4 = g(b);
|
||||||
|
>z4 : Symbol(z4, Decl(stringEnumLiteralTypes2.ts, 40, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 36, 21))
|
||||||
|
|
||||||
|
var z5 = g(c);
|
||||||
|
>z5 : Symbol(z5, Decl(stringEnumLiteralTypes2.ts, 41, 7))
|
||||||
|
>g : Symbol(g, Decl(stringEnumLiteralTypes2.ts, 30, 1), Decl(stringEnumLiteralTypes2.ts, 32, 42), Decl(stringEnumLiteralTypes2.ts, 33, 42))
|
||||||
|
>c : Symbol(c, Decl(stringEnumLiteralTypes2.ts, 36, 38))
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes2.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 44, 21))
|
||||||
|
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
>f10 : Symbol(f10, Decl(stringEnumLiteralTypes2.ts, 46, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 48, 13))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 48, 13))
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
>f11 : Symbol(f11, Decl(stringEnumLiteralTypes2.ts, 53, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 55, 13))
|
||||||
|
>YesNo : Symbol(YesNo, Decl(stringEnumLiteralTypes2.ts, 0, 59))
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 55, 13))
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes2.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 55, 13))
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
>f12 : Symbol(f12, Decl(stringEnumLiteralTypes2.ts, 61, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 63, 13))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes2.ts, 3, 36))
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 63, 13))
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 63, 13))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 63, 13))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
>f13 : Symbol(f13, Decl(stringEnumLiteralTypes2.ts, 70, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 72, 13))
|
||||||
|
>UnknownYesNo : Symbol(UnknownYesNo, Decl(stringEnumLiteralTypes2.ts, 3, 36))
|
||||||
|
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 72, 13))
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 72, 13))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 72, 13))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes2.ts, 79, 1))
|
||||||
|
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 82, 5))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 82, 23))
|
||||||
|
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 83, 5))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 83, 22))
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
>f20 : Symbol(f20, Decl(stringEnumLiteralTypes2.ts, 83, 35))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 85, 13))
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes2.ts, 79, 1))
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 82, 5), Decl(stringEnumLiteralTypes2.ts, 83, 5))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 85, 13))
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 82, 5), Decl(stringEnumLiteralTypes2.ts, 83, 5))
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>x.a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 82, 23))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 85, 13))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 82, 23))
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>x.b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 83, 22))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 85, 13))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 83, 22))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
>f21 : Symbol(f21, Decl(stringEnumLiteralTypes2.ts, 90, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 92, 13))
|
||||||
|
>Item : Symbol(Item, Decl(stringEnumLiteralTypes2.ts, 79, 1))
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 82, 5), Decl(stringEnumLiteralTypes2.ts, 83, 5))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 92, 13))
|
||||||
|
>kind : Symbol(kind, Decl(stringEnumLiteralTypes2.ts, 82, 5), Decl(stringEnumLiteralTypes2.ts, 83, 5))
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>Yes : Symbol(Choice.Yes, Decl(stringEnumLiteralTypes2.ts, 0, 33))
|
||||||
|
>x.a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 82, 23))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 92, 13))
|
||||||
|
>a : Symbol(a, Decl(stringEnumLiteralTypes2.ts, 82, 23))
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>Choice : Symbol(Choice, Decl(stringEnumLiteralTypes2.ts, 0, 0))
|
||||||
|
>No : Symbol(Choice.No, Decl(stringEnumLiteralTypes2.ts, 0, 46))
|
||||||
|
>x.b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 83, 22))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 92, 13))
|
||||||
|
>b : Symbol(b, Decl(stringEnumLiteralTypes2.ts, 83, 22))
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever : Symbol(assertNever, Decl(stringEnumLiteralTypes2.ts, 42, 1))
|
||||||
|
>x : Symbol(x, Decl(stringEnumLiteralTypes2.ts, 92, 13))
|
||||||
|
}
|
383
tests/baselines/reference/stringEnumLiteralTypes2.types
Normal file
383
tests/baselines/reference/stringEnumLiteralTypes2.types
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
=== tests/cases/conformance/types/literal/stringEnumLiteralTypes2.ts ===
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
>Choice : Choice
|
||||||
|
>Unknown : Choice.Unknown
|
||||||
|
>"" : ""
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"yes" : "yes"
|
||||||
|
>No : Choice.No
|
||||||
|
>"no" : "no"
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
>YesNo : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
>NoYes : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>Choice : any
|
||||||
|
>Unknown : Choice.Unknown
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
>f1 : () => void
|
||||||
|
|
||||||
|
var a: YesNo;
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
var a: NoYes;
|
||||||
|
>a : YesNo
|
||||||
|
>NoYes : YesNo
|
||||||
|
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
>a : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
>a : YesNo
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f2 : (a: YesNo, b: Choice, c: Choice) => void
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>c : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
b = a;
|
||||||
|
>b = a : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
c = a;
|
||||||
|
>c = a : YesNo
|
||||||
|
>c : Choice
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
c = b;
|
||||||
|
>c = b : YesNo
|
||||||
|
>c : Choice
|
||||||
|
>b : YesNo
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
>f3 : (a: Choice.Yes, b: YesNo) => void
|
||||||
|
>a : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
var x = a + b;
|
||||||
|
>x : string
|
||||||
|
>a + b : string
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a == b;
|
||||||
|
>y : boolean
|
||||||
|
>a == b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a != b;
|
||||||
|
>y : boolean
|
||||||
|
>a != b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a === b;
|
||||||
|
>y : boolean
|
||||||
|
>a === b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a !== b;
|
||||||
|
>y : boolean
|
||||||
|
>a !== b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a > b;
|
||||||
|
>y : boolean
|
||||||
|
>a > b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a < b;
|
||||||
|
>y : boolean
|
||||||
|
>a < b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a >= b;
|
||||||
|
>y : boolean
|
||||||
|
>a >= b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = a <= b;
|
||||||
|
>y : boolean
|
||||||
|
>a <= b : boolean
|
||||||
|
>a : Choice.Yes
|
||||||
|
>b : YesNo
|
||||||
|
|
||||||
|
var y = !b;
|
||||||
|
>y : boolean
|
||||||
|
>!b : false
|
||||||
|
>b : YesNo
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>x : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
>f5 : (a: YesNo, b: Choice, c: Choice) => void
|
||||||
|
>a : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
>b : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
>c : Choice
|
||||||
|
>Choice : Choice
|
||||||
|
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
>z1 : string
|
||||||
|
>g(Choice.Yes) : string
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
>z2 : boolean
|
||||||
|
>g(Choice.No) : boolean
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
|
||||||
|
var z3 = g(a);
|
||||||
|
>z3 : number
|
||||||
|
>g(a) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>a : YesNo
|
||||||
|
|
||||||
|
var z4 = g(b);
|
||||||
|
>z4 : number
|
||||||
|
>g(b) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>b : Choice
|
||||||
|
|
||||||
|
var z5 = g(c);
|
||||||
|
>z5 : number
|
||||||
|
>g(c) : number
|
||||||
|
>g : { (x: Choice.Yes): string; (x: Choice.No): boolean; (x: Choice): number; }
|
||||||
|
>c : Choice
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
>new Error("Unexpected value") : Error
|
||||||
|
>Error : ErrorConstructor
|
||||||
|
>"Unexpected value" : "Unexpected value"
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
>f10 : (x: YesNo) => "true" | "false"
|
||||||
|
>x : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"true" : "true"
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>"false" : "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
>f11 : (x: YesNo) => "true" | "false"
|
||||||
|
>x : YesNo
|
||||||
|
>YesNo : YesNo
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
>x : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>"true" : "true"
|
||||||
|
|
||||||
|
case Choice.No: return "false";
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>"false" : "false"
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever(x) : never
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
>f12 : (x: Choice) => void
|
||||||
|
>x : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
>x : Choice
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : YesNo
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Choice.Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
>f13 : (x: Choice) => void
|
||||||
|
>x : Choice
|
||||||
|
>UnknownYesNo : Choice
|
||||||
|
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
>x === Choice.Yes : boolean
|
||||||
|
>x : Choice
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
|
||||||
|
x;
|
||||||
|
>x : Choice.Yes
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
>x : Choice.Unknown | Choice.No
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
>kind : Choice.Yes
|
||||||
|
>Choice : any
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
>kind : Choice.No
|
||||||
|
>Choice : any
|
||||||
|
>No : Choice.No
|
||||||
|
>b : string
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
>f20 : (x: Item) => string
|
||||||
|
>x : Item
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : YesNo
|
||||||
|
>x : Item
|
||||||
|
>kind : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>x.a : string
|
||||||
|
>x : { kind: Choice.Yes; a: string; }
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>x.b : string
|
||||||
|
>x : { kind: Choice.No; b: string; }
|
||||||
|
>b : string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
>f21 : (x: Item) => string
|
||||||
|
>x : Item
|
||||||
|
>Item : Item
|
||||||
|
|
||||||
|
switch (x.kind) {
|
||||||
|
>x.kind : YesNo
|
||||||
|
>x : Item
|
||||||
|
>kind : YesNo
|
||||||
|
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
>Choice.Yes : Choice.Yes
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>Yes : Choice.Yes
|
||||||
|
>x.a : string
|
||||||
|
>x : { kind: Choice.Yes; a: string; }
|
||||||
|
>a : string
|
||||||
|
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
>Choice.No : Choice.No
|
||||||
|
>Choice : typeof Choice
|
||||||
|
>No : Choice.No
|
||||||
|
>x.b : string
|
||||||
|
>x : { kind: Choice.No; b: string; }
|
||||||
|
>b : string
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
>assertNever(x) : never
|
||||||
|
>assertNever : (x: never) => never
|
||||||
|
>x : never
|
||||||
|
}
|
166
tests/baselines/reference/stringEnumLiteralTypes3.errors.txt
Normal file
166
tests/baselines/reference/stringEnumLiteralTypes3.errors.txt
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(10,5): error TS2322: Type 'YesNo' is not assignable to type 'Choice.Yes'.
|
||||||
|
Type 'Choice.No' is not assignable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(11,5): error TS2322: Type 'Choice' is not assignable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(12,5): error TS2322: Type 'Choice' is not assignable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(18,5): error TS2322: Type 'Choice' is not assignable to type 'YesNo'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(19,5): error TS2322: Type 'Choice' is not assignable to type 'YesNo'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(37,5): error TS2322: Type 'Choice.Unknown' is not assignable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(39,5): error TS2322: Type 'Choice.No' is not assignable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(40,5): error TS2322: Type 'Choice.Unknown' is not assignable to type 'YesNo'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(52,5): error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.Unknown'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(54,5): error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.No'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(55,5): error TS2365: Operator '===' cannot be applied to types 'YesNo' and 'Choice.Unknown'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(87,14): error TS2678: Type 'Choice.Unknown' is not comparable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(89,14): error TS2678: Type 'Choice.No' is not comparable to type 'Choice.Yes'.
|
||||||
|
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts(96,14): error TS2678: Type 'Choice.Unknown' is not comparable to type 'YesNo'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts (14 errors) ====
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type Yes = Choice.Yes;
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = a;
|
||||||
|
a = b;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'YesNo' is not assignable to type 'Choice.Yes'.
|
||||||
|
!!! error TS2322: Type 'Choice.No' is not assignable to type 'Choice.Yes'.
|
||||||
|
a = c;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice' is not assignable to type 'Choice.Yes'.
|
||||||
|
a = d;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice' is not assignable to type 'Choice.Yes'.
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
b = a;
|
||||||
|
b = b;
|
||||||
|
b = c;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice' is not assignable to type 'YesNo'.
|
||||||
|
b = d;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice' is not assignable to type 'YesNo'.
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
c = c;
|
||||||
|
c = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f4(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
d = a;
|
||||||
|
d = b;
|
||||||
|
d = c;
|
||||||
|
d = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f5(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = Choice.Unknown;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice.Unknown' is not assignable to type 'Choice.Yes'.
|
||||||
|
a = Choice.Yes;
|
||||||
|
a = Choice.No;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice.No' is not assignable to type 'Choice.Yes'.
|
||||||
|
b = Choice.Unknown;
|
||||||
|
~
|
||||||
|
!!! error TS2322: Type 'Choice.Unknown' is not assignable to type 'YesNo'.
|
||||||
|
b = Choice.Yes;
|
||||||
|
b = Choice.No;
|
||||||
|
c = Choice.Unknown;
|
||||||
|
c = Choice.Yes;
|
||||||
|
c = Choice.No;
|
||||||
|
d = Choice.Unknown;
|
||||||
|
d = Choice.Yes;
|
||||||
|
d = Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f6(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === Choice.Unknown;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.Unknown'.
|
||||||
|
a === Choice.Yes;
|
||||||
|
a === Choice.No;
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.No'.
|
||||||
|
b === Choice.Unknown;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2365: Operator '===' cannot be applied to types 'YesNo' and 'Choice.Unknown'.
|
||||||
|
b === Choice.Yes;
|
||||||
|
b === Choice.No;
|
||||||
|
c === Choice.Unknown;
|
||||||
|
c === Choice.Yes;
|
||||||
|
c === Choice.No;
|
||||||
|
d === Choice.Unknown;
|
||||||
|
d === Choice.Yes;
|
||||||
|
d === Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f7(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === a;
|
||||||
|
a === b;
|
||||||
|
a === c;
|
||||||
|
a === d;
|
||||||
|
b === a;
|
||||||
|
b === b;
|
||||||
|
b === c;
|
||||||
|
b === d;
|
||||||
|
c === a;
|
||||||
|
c === b;
|
||||||
|
c === c;
|
||||||
|
c === d;
|
||||||
|
d === a;
|
||||||
|
d === b;
|
||||||
|
d === c;
|
||||||
|
d === d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: Yes): Yes {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2678: Type 'Choice.Unknown' is not comparable to type 'Choice.Yes'.
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
~~~~~~~~~
|
||||||
|
!!! error TS2678: Type 'Choice.No' is not comparable to type 'Choice.Yes'.
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo): YesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2678: Type 'Choice.Unknown' is not comparable to type 'YesNo'.
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo): UnknownYesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: Choice): Choice {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
225
tests/baselines/reference/stringEnumLiteralTypes3.js
Normal file
225
tests/baselines/reference/stringEnumLiteralTypes3.js
Normal file
|
@ -0,0 +1,225 @@
|
||||||
|
//// [stringEnumLiteralTypes3.ts]
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type Yes = Choice.Yes;
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = a;
|
||||||
|
a = b;
|
||||||
|
a = c;
|
||||||
|
a = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
b = a;
|
||||||
|
b = b;
|
||||||
|
b = c;
|
||||||
|
b = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
c = c;
|
||||||
|
c = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f4(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
d = a;
|
||||||
|
d = b;
|
||||||
|
d = c;
|
||||||
|
d = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f5(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = Choice.Unknown;
|
||||||
|
a = Choice.Yes;
|
||||||
|
a = Choice.No;
|
||||||
|
b = Choice.Unknown;
|
||||||
|
b = Choice.Yes;
|
||||||
|
b = Choice.No;
|
||||||
|
c = Choice.Unknown;
|
||||||
|
c = Choice.Yes;
|
||||||
|
c = Choice.No;
|
||||||
|
d = Choice.Unknown;
|
||||||
|
d = Choice.Yes;
|
||||||
|
d = Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f6(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === Choice.Unknown;
|
||||||
|
a === Choice.Yes;
|
||||||
|
a === Choice.No;
|
||||||
|
b === Choice.Unknown;
|
||||||
|
b === Choice.Yes;
|
||||||
|
b === Choice.No;
|
||||||
|
c === Choice.Unknown;
|
||||||
|
c === Choice.Yes;
|
||||||
|
c === Choice.No;
|
||||||
|
d === Choice.Unknown;
|
||||||
|
d === Choice.Yes;
|
||||||
|
d === Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f7(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === a;
|
||||||
|
a === b;
|
||||||
|
a === c;
|
||||||
|
a === d;
|
||||||
|
b === a;
|
||||||
|
b === b;
|
||||||
|
b === c;
|
||||||
|
b === d;
|
||||||
|
c === a;
|
||||||
|
c === b;
|
||||||
|
c === c;
|
||||||
|
c === d;
|
||||||
|
d === a;
|
||||||
|
d === b;
|
||||||
|
d === c;
|
||||||
|
d === d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: Yes): Yes {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo): YesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo): UnknownYesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: Choice): Choice {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [stringEnumLiteralTypes3.js]
|
||||||
|
;
|
||||||
|
function f1(a, b, c, d) {
|
||||||
|
a = a;
|
||||||
|
a = b;
|
||||||
|
a = c;
|
||||||
|
a = d;
|
||||||
|
}
|
||||||
|
function f2(a, b, c, d) {
|
||||||
|
b = a;
|
||||||
|
b = b;
|
||||||
|
b = c;
|
||||||
|
b = d;
|
||||||
|
}
|
||||||
|
function f3(a, b, c, d) {
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
c = c;
|
||||||
|
c = d;
|
||||||
|
}
|
||||||
|
function f4(a, b, c, d) {
|
||||||
|
d = a;
|
||||||
|
d = b;
|
||||||
|
d = c;
|
||||||
|
d = d;
|
||||||
|
}
|
||||||
|
function f5(a, b, c, d) {
|
||||||
|
a = "" /* Unknown */;
|
||||||
|
a = "yes" /* Yes */;
|
||||||
|
a = "no" /* No */;
|
||||||
|
b = "" /* Unknown */;
|
||||||
|
b = "yes" /* Yes */;
|
||||||
|
b = "no" /* No */;
|
||||||
|
c = "" /* Unknown */;
|
||||||
|
c = "yes" /* Yes */;
|
||||||
|
c = "no" /* No */;
|
||||||
|
d = "" /* Unknown */;
|
||||||
|
d = "yes" /* Yes */;
|
||||||
|
d = "no" /* No */;
|
||||||
|
}
|
||||||
|
function f6(a, b, c, d) {
|
||||||
|
a === "" /* Unknown */;
|
||||||
|
a === "yes" /* Yes */;
|
||||||
|
a === "no" /* No */;
|
||||||
|
b === "" /* Unknown */;
|
||||||
|
b === "yes" /* Yes */;
|
||||||
|
b === "no" /* No */;
|
||||||
|
c === "" /* Unknown */;
|
||||||
|
c === "yes" /* Yes */;
|
||||||
|
c === "no" /* No */;
|
||||||
|
d === "" /* Unknown */;
|
||||||
|
d === "yes" /* Yes */;
|
||||||
|
d === "no" /* No */;
|
||||||
|
}
|
||||||
|
function f7(a, b, c, d) {
|
||||||
|
a === a;
|
||||||
|
a === b;
|
||||||
|
a === c;
|
||||||
|
a === d;
|
||||||
|
b === a;
|
||||||
|
b === b;
|
||||||
|
b === c;
|
||||||
|
b === d;
|
||||||
|
c === a;
|
||||||
|
c === b;
|
||||||
|
c === c;
|
||||||
|
c === d;
|
||||||
|
d === a;
|
||||||
|
d === b;
|
||||||
|
d === c;
|
||||||
|
d === d;
|
||||||
|
}
|
||||||
|
function f10(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "" /* Unknown */: return x;
|
||||||
|
case "yes" /* Yes */: return x;
|
||||||
|
case "no" /* No */: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
function f11(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "" /* Unknown */: return x;
|
||||||
|
case "yes" /* Yes */: return x;
|
||||||
|
case "no" /* No */: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
function f12(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "" /* Unknown */: return x;
|
||||||
|
case "yes" /* Yes */: return x;
|
||||||
|
case "no" /* No */: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
function f13(x) {
|
||||||
|
switch (x) {
|
||||||
|
case "" /* Unknown */: return x;
|
||||||
|
case "yes" /* Yes */: return x;
|
||||||
|
case "no" /* No */: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
|
@ -12,21 +12,21 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts (29 errors) ====
|
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts (29 errors) ====
|
||||||
|
@ -94,49 +94,49 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
||||||
foo: any; // ok
|
foo: any; // ok
|
||||||
foo2: string; // error
|
foo2: string; // error
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number'.
|
||||||
foo3: number; // ok
|
foo3: number; // ok
|
||||||
foo4: boolean; // error
|
foo4: boolean; // error
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number'.
|
||||||
foo5: E; // ok
|
foo5: E; // ok
|
||||||
foo6: Date; // error
|
foo6: Date; // error
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number'.
|
||||||
foo7: RegExp; // error
|
foo7: RegExp; // error
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number'.
|
||||||
foo8: { bar: number }; // error
|
foo8: { bar: number }; // error
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number'.
|
||||||
foo9: I8; // error
|
foo9: I8; // error
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number'.
|
||||||
foo10: A; // error
|
foo10: A; // error
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number'.
|
||||||
foo11: A2<number>; // error
|
foo11: A2<number>; // error
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number'.
|
||||||
foo12: (x) => number; //error
|
foo12: (x) => number; //error
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number'.
|
||||||
foo13: <T>(x: T) => T; // error
|
foo13: <T>(x: T) => T; // error
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number'.
|
||||||
foo14: typeof f; // error
|
foo14: typeof f; // error
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number'.
|
||||||
foo15: typeof c; // error
|
foo15: typeof c; // error
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number'.
|
||||||
foo16: T; // error
|
foo16: T; // error
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number'.
|
||||||
foo17: Object; // error
|
foo17: Object; // error
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number'.
|
||||||
foo18: {}; // error
|
foo18: {}; // error
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'.
|
!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number'.
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
tests/cases/conformance/jsx/file.tsx(21,16): error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'.
|
tests/cases/conformance/jsx/file.tsx(21,16): error TS2322: Type 'T' is not assignable to type 'Attribs1'.
|
||||||
Types of property 'x' are incompatible.
|
Type '{ x: number; }' is not assignable to type 'Attribs1'.
|
||||||
Type 'number' is not assignable to type 'string'.
|
Types of property 'x' are incompatible.
|
||||||
tests/cases/conformance/jsx/file.tsx(25,16): error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
Type 'number' is not assignable to type 'string'.
|
||||||
Property 'x' is missing in type '{ y: string; }'.
|
tests/cases/conformance/jsx/file.tsx(25,16): error TS2322: Type 'T' is not assignable to type 'Attribs1'.
|
||||||
|
Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
||||||
|
Property 'x' is missing in type '{ y: string; }'.
|
||||||
tests/cases/conformance/jsx/file.tsx(29,8): error TS2322: Type '{}' is not assignable to type 'Attribs1'.
|
tests/cases/conformance/jsx/file.tsx(29,8): error TS2322: Type '{}' is not assignable to type 'Attribs1'.
|
||||||
Property 'x' is missing in type '{}'.
|
Property 'x' is missing in type '{}'.
|
||||||
|
|
||||||
|
@ -30,16 +32,18 @@ tests/cases/conformance/jsx/file.tsx(29,8): error TS2322: Type '{}' is not assig
|
||||||
function make2<T extends {x: number}> (obj: T) {
|
function make2<T extends {x: number}> (obj: T) {
|
||||||
return <test1 {...obj} />; // Error (x is number, not string)
|
return <test1 {...obj} />; // Error (x is number, not string)
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'.
|
!!! error TS2322: Type 'T' is not assignable to type 'Attribs1'.
|
||||||
!!! error TS2322: Types of property 'x' are incompatible.
|
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'.
|
||||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
!!! error TS2322: Types of property 'x' are incompatible.
|
||||||
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||||
}
|
}
|
||||||
|
|
||||||
function make3<T extends {y: string}> (obj: T) {
|
function make3<T extends {y: string}> (obj: T) {
|
||||||
return <test1 {...obj} />; // Error, missing x
|
return <test1 {...obj} />; // Error, missing x
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
!!! error TS2322: Type 'T' is not assignable to type 'Attribs1'.
|
||||||
!!! error TS2322: Property 'x' is missing in type '{ y: string; }'.
|
!!! error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
||||||
|
!!! error TS2322: Property 'x' is missing in type '{ y: string; }'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
40
tests/baselines/reference/tsxGenericAttributesType9.js
Normal file
40
tests/baselines/reference/tsxGenericAttributesType9.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//// [file.tsx]
|
||||||
|
import React = require('react');
|
||||||
|
|
||||||
|
export function makeP<P>(Ctor: React.ComponentClass<P>): React.ComponentClass<P> {
|
||||||
|
return class extends React.PureComponent<P, void> {
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<Ctor {...this.props } />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//// [file.jsx]
|
||||||
|
"use strict";
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
exports.__esModule = true;
|
||||||
|
var React = require("react");
|
||||||
|
function makeP(Ctor) {
|
||||||
|
return (function (_super) {
|
||||||
|
__extends(class_1, _super);
|
||||||
|
function class_1() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
class_1.prototype.render = function () {
|
||||||
|
return (<Ctor {...this.props}/>);
|
||||||
|
};
|
||||||
|
return class_1;
|
||||||
|
}(React.PureComponent));
|
||||||
|
}
|
||||||
|
exports.makeP = makeP;
|
37
tests/baselines/reference/tsxGenericAttributesType9.symbols
Normal file
37
tests/baselines/reference/tsxGenericAttributesType9.symbols
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
=== tests/cases/conformance/jsx/file.tsx ===
|
||||||
|
import React = require('react');
|
||||||
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
||||||
|
|
||||||
|
export function makeP<P>(Ctor: React.ComponentClass<P>): React.ComponentClass<P> {
|
||||||
|
>makeP : Symbol(makeP, Decl(file.tsx, 0, 32))
|
||||||
|
>P : Symbol(P, Decl(file.tsx, 2, 22))
|
||||||
|
>Ctor : Symbol(Ctor, Decl(file.tsx, 2, 25))
|
||||||
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
||||||
|
>ComponentClass : Symbol(React.ComponentClass, Decl(react.d.ts, 204, 5))
|
||||||
|
>P : Symbol(P, Decl(file.tsx, 2, 22))
|
||||||
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
||||||
|
>ComponentClass : Symbol(React.ComponentClass, Decl(react.d.ts, 204, 5))
|
||||||
|
>P : Symbol(P, Decl(file.tsx, 2, 22))
|
||||||
|
|
||||||
|
return class extends React.PureComponent<P, void> {
|
||||||
|
>React.PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 179, 5))
|
||||||
|
>React : Symbol(React, Decl(file.tsx, 0, 0))
|
||||||
|
>PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 179, 5))
|
||||||
|
>P : Symbol(P, Decl(file.tsx, 2, 22))
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
>render : Symbol((Anonymous class).render, Decl(file.tsx, 3, 52))
|
||||||
|
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
|
||||||
|
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Ctor {...this.props } />
|
||||||
|
>Ctor : Symbol(Ctor, Decl(file.tsx, 2, 25))
|
||||||
|
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||||
|
>this : Symbol((Anonymous class), Decl(file.tsx, 3, 7))
|
||||||
|
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
41
tests/baselines/reference/tsxGenericAttributesType9.types
Normal file
41
tests/baselines/reference/tsxGenericAttributesType9.types
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
=== tests/cases/conformance/jsx/file.tsx ===
|
||||||
|
import React = require('react');
|
||||||
|
>React : typeof React
|
||||||
|
|
||||||
|
export function makeP<P>(Ctor: React.ComponentClass<P>): React.ComponentClass<P> {
|
||||||
|
>makeP : <P>(Ctor: React.ComponentClass<P>) => React.ComponentClass<P>
|
||||||
|
>P : P
|
||||||
|
>Ctor : React.ComponentClass<P>
|
||||||
|
>React : any
|
||||||
|
>ComponentClass : React.ComponentClass<P>
|
||||||
|
>P : P
|
||||||
|
>React : any
|
||||||
|
>ComponentClass : React.ComponentClass<P>
|
||||||
|
>P : P
|
||||||
|
|
||||||
|
return class extends React.PureComponent<P, void> {
|
||||||
|
>class extends React.PureComponent<P, void> { public render(): JSX.Element { return ( <Ctor {...this.props } /> ); } } : typeof (Anonymous class)
|
||||||
|
>React.PureComponent : React.PureComponent<P, void>
|
||||||
|
>React : typeof React
|
||||||
|
>PureComponent : typeof React.PureComponent
|
||||||
|
>P : P
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
>render : () => JSX.Element
|
||||||
|
>JSX : any
|
||||||
|
>Element : JSX.Element
|
||||||
|
|
||||||
|
return (
|
||||||
|
>( <Ctor {...this.props } /> ) : JSX.Element
|
||||||
|
|
||||||
|
<Ctor {...this.props } />
|
||||||
|
><Ctor {...this.props } /> : JSX.Element
|
||||||
|
>Ctor : React.ComponentClass<P>
|
||||||
|
>this.props : P & { children?: React.ReactNode; }
|
||||||
|
>this : this
|
||||||
|
>props : P & { children?: React.ReactNode; }
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
tests/cases/conformance/jsx/file.tsx(8,34): error TS2322: Type '{ ignore-prop: 10; prop: number; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
|
tests/cases/conformance/jsx/file.tsx(8,34): error TS2322: Type 'T & { ignore-prop: 10; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
|
||||||
Type '{ ignore-prop: 10; prop: number; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
|
Type 'T & { ignore-prop: 10; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
|
||||||
Types of property '"ignore-prop"' are incompatible.
|
Types of property '"ignore-prop"' are incompatible.
|
||||||
Type '10' is not assignable to type 'string'.
|
Type '10' is not assignable to type 'string'.
|
||||||
tests/cases/conformance/jsx/file.tsx(13,34): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
|
tests/cases/conformance/jsx/file.tsx(13,34): error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
|
||||||
Type '{}' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
|
Type 'T' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
|
||||||
Property 'prop' is missing in type '{}'.
|
|
||||||
tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '{ func: (a: number, b: string) => void; }' is not assignable to type 'IntrinsicAttributes & { func: (arg: number) => void; }'.
|
tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '{ func: (a: number, b: string) => void; }' is not assignable to type 'IntrinsicAttributes & { func: (arg: number) => void; }'.
|
||||||
Type '{ func: (a: number, b: string) => void; }' is not assignable to type '{ func: (arg: number) => void; }'.
|
Type '{ func: (a: number, b: string) => void; }' is not assignable to type '{ func: (arg: number) => void; }'.
|
||||||
Types of property 'func' are incompatible.
|
Types of property 'func' are incompatible.
|
||||||
|
@ -25,8 +24,8 @@ tests/cases/conformance/jsx/file.tsx(31,10): error TS2453: The type argument for
|
||||||
function Bar<T extends {prop: number}>(arg: T) {
|
function Bar<T extends {prop: number}>(arg: T) {
|
||||||
let a1 = <ComponentSpecific1 {...arg} ignore-prop={10} />;
|
let a1 = <ComponentSpecific1 {...arg} ignore-prop={10} />;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2322: Type '{ ignore-prop: 10; prop: number; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
|
!!! error TS2322: Type 'T & { ignore-prop: 10; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
|
||||||
!!! error TS2322: Type '{ ignore-prop: 10; prop: number; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
|
!!! error TS2322: Type 'T & { ignore-prop: 10; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
|
||||||
!!! error TS2322: Types of property '"ignore-prop"' are incompatible.
|
!!! error TS2322: Types of property '"ignore-prop"' are incompatible.
|
||||||
!!! error TS2322: Type '10' is not assignable to type 'string'.
|
!!! error TS2322: Type '10' is not assignable to type 'string'.
|
||||||
}
|
}
|
||||||
|
@ -35,9 +34,8 @@ tests/cases/conformance/jsx/file.tsx(31,10): error TS2453: The type argument for
|
||||||
function Baz<T>(arg: T) {
|
function Baz<T>(arg: T) {
|
||||||
let a0 = <ComponentSpecific1 {...arg} />
|
let a0 = <ComponentSpecific1 {...arg} />
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
|
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
|
||||||
!!! error TS2322: Type '{}' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
|
!!! error TS2322: Type 'T' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
|
||||||
!!! error TS2322: Property 'prop' is missing in type '{}'.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
|
declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
tests/cases/conformance/jsx/file.tsx(9,33): error TS2322: Type '{ a: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: number; }'.
|
tests/cases/conformance/jsx/file.tsx(9,33): error TS2322: Type '{ a: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: number; }'.
|
||||||
Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
||||||
Property 'b' is missing in type '{ a: number; }'.
|
Property 'b' is missing in type '{ a: number; }'.
|
||||||
tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
||||||
Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
||||||
Property 'a' is missing in type '{ b: number; }'.
|
Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
Type 'T' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
Property 'a' is missing in type '{ b: number; }'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
|
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
|
||||||
|
@ -22,7 +25,10 @@ tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type '{ b: number; }'
|
||||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||||
let a2 = <OverloadComponent {...arg1} ignore-prop /> // missing a
|
let a2 = <OverloadComponent {...arg1} ignore-prop /> // missing a
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2322: Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
||||||
!!! error TS2322: Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
!!! error TS2322: Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
|
||||||
!!! error TS2322: Property 'a' is missing in type '{ b: number; }'.
|
!!! error TS2322: Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
!!! error TS2322: Type 'T' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
!!! error TS2322: Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
|
||||||
|
!!! error TS2322: Property 'a' is missing in type '{ b: number; }'.
|
||||||
}
|
}
|
|
@ -1,7 +1,11 @@
|
||||||
|
tests/cases/conformance/jsx/file.tsx(15,14): error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
|
||||||
|
Property 'render' is missing in type 'Element'.
|
||||||
|
tests/cases/conformance/jsx/file.tsx(15,15): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||||
|
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate '"hello"'.
|
||||||
tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||||
import React = require('react')
|
import React = require('react')
|
||||||
|
|
||||||
declare function Component<U>(l: U): JSX.Element;
|
declare function Component<U>(l: U): JSX.Element;
|
||||||
|
@ -17,6 +21,12 @@ tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does
|
||||||
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
|
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
|
||||||
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
|
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
|
||||||
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
|
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
|
||||||
|
!!! error TS2605: Property 'render' is missing in type 'Element'.
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||||
|
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate '"hello"'.
|
||||||
let a4 = <ComponentSpecific {...arg} prop1="hello" />; // U is "hello"
|
let a4 = <ComponentSpecific {...arg} prop1="hello" />; // U is "hello"
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
!!! error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(30,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
||||||
Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate '0'.
|
|
||||||
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(35,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(35,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||||
Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate 'E2'.
|
Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate 'E2'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts (2 errors) ====
|
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts (1 errors) ====
|
||||||
interface Computed<T> {
|
interface Computed<T> {
|
||||||
read(): T;
|
read(): T;
|
||||||
write(value: T);
|
write(value: T);
|
||||||
|
@ -35,9 +33,6 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjec
|
||||||
var v1 = f1({ w: x => x, r: () => 0 }, 0);
|
var v1 = f1({ w: x => x, r: () => 0 }, 0);
|
||||||
var v1 = f1({ w: x => x, r: () => 0 }, E1.X);
|
var v1 = f1({ w: x => x, r: () => 0 }, E1.X);
|
||||||
var v1 = f1({ w: x => x, r: () => E1.X }, 0);
|
var v1 = f1({ w: x => x, r: () => E1.X }, 0);
|
||||||
~~
|
|
||||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
||||||
!!! error TS2453: Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate '0'.
|
|
||||||
|
|
||||||
var v2: E1;
|
var v2: E1;
|
||||||
var v2 = f1({ w: x => x, r: () => E1.X }, E1.X);
|
var v2 = f1({ w: x => x, r: () => E1.X }, E1.X);
|
||||||
|
|
5
tests/baselines/reference/unicodeStringLiteral.js
Normal file
5
tests/baselines/reference/unicodeStringLiteral.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
//// [unicodeStringLiteral.ts]
|
||||||
|
var ੳ = "Üਲĭ";
|
||||||
|
|
||||||
|
//// [unicodeStringLiteral.js]
|
||||||
|
var ੳ = "Üਲĭ";
|
4
tests/baselines/reference/unicodeStringLiteral.symbols
Normal file
4
tests/baselines/reference/unicodeStringLiteral.symbols
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
=== tests/cases/compiler/unicodeStringLiteral.ts ===
|
||||||
|
var ੳ = "Üਲĭ";
|
||||||
|
>ੳ : Symbol(ੳ, Decl(unicodeStringLiteral.ts, 0, 3))
|
||||||
|
|
5
tests/baselines/reference/unicodeStringLiteral.types
Normal file
5
tests/baselines/reference/unicodeStringLiteral.types
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
=== tests/cases/compiler/unicodeStringLiteral.ts ===
|
||||||
|
var ੳ = "Üਲĭ";
|
||||||
|
>ੳ : string
|
||||||
|
>"Üਲĭ" : "Üਲ\u000Eĭ"
|
||||||
|
|
|
@ -1,37 +1,36 @@
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(15,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(15,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(21,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(21,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(22,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'string'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(22,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'string'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(28,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(28,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(29,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'boolean'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(29,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'boolean'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(35,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(35,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(36,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'Date'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(36,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'Date'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(42,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(42,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(43,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'RegExp'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(43,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'RegExp'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(49,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(49,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(50,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '{ bar: number; }'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(50,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '{ bar: number; }'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(56,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(56,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(57,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'number[]'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(57,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'number[]'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(63,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(63,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(64,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'I8'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(64,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'I8'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(70,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(70,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(71,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(71,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'A'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(77,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2<number>'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(77,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2<number>'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(78,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A2<number>'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(78,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'A2<number>'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(84,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(84,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(85,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: any) => number'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(85,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '(x: any) => number'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(91,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '<T>(x: T) => T'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(91,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '<T>(x: T) => T'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(92,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '<T>(x: T) => T'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(92,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '<T>(x: T) => T'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(99,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(99,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(100,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'E2'.
|
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(110,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(110,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(111,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof f'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(111,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'typeof f'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(121,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(121,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(122,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof c'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(122,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'typeof c'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(128,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(128,5): error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'.
|
||||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(129,5): error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'T'.
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts(129,5): error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'T'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts (31 errors) ====
|
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubtypeIfEveryConstituentTypeIsSubtype.ts (30 errors) ====
|
||||||
enum e {
|
enum e {
|
||||||
e1,
|
e1,
|
||||||
e2
|
e2
|
||||||
|
@ -59,7 +58,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'string'.
|
||||||
foo2: e | number; // error e and number both not subtype of string
|
foo2: e | number; // error e and number both not subtype of string
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'string'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'string'.
|
||||||
}
|
}
|
||||||
|
|
||||||
// error cases
|
// error cases
|
||||||
|
@ -70,7 +69,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'boolean'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'boolean'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'boolean'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'Date'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'Date'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'Date'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'RegExp'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'RegExp'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'RegExp'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +102,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '{ bar: number; }'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '{ bar: number; }'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '{ bar: number; }'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +113,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'number[]'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'number[]'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'number[]'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +124,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'I8'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'I8'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'I8'.
|
||||||
}
|
}
|
||||||
|
|
||||||
class A { foo: number; }
|
class A { foo: number; }
|
||||||
|
@ -136,7 +135,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'A'.
|
||||||
}
|
}
|
||||||
|
|
||||||
class A2<T> { foo: T; }
|
class A2<T> { foo: T; }
|
||||||
|
@ -147,7 +146,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2<number>'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'A2<number>'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'A2<number>'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'A2<number>'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +157,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '(x: any) => number'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '(x: any) => number'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '(x: any) => number'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '<T>(x: T) => T'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type '<T>(x: T) => T'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type '<T>(x: T) => T'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type '<T>(x: T) => T'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,8 +179,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'E2'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'E2'.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,7 +193,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof f'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof f'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'typeof f'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,7 +208,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'typeof c'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'typeof c'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'typeof c'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +219,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/unionSubty
|
||||||
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'.
|
!!! error TS2411: Property 'foo' of type 'string | number' is not assignable to string index type 'T'.
|
||||||
foo2: e | number;
|
foo2: e | number;
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! error TS2411: Property 'foo2' of type 'number | e' is not assignable to string index type 'T'.
|
!!! error TS2411: Property 'foo2' of type 'number' is not assignable to string index type 'T'.
|
||||||
}
|
}
|
||||||
|
|
||||||
interface I19 {
|
interface I19 {
|
||||||
|
|
2
tests/cases/compiler/objectLiteralFreshnessWithSpread.ts
Normal file
2
tests/cases/compiler/objectLiteralFreshnessWithSpread.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
let x = { b: 1, extra: 2 }
|
||||||
|
let xx: { a, b } = { a: 1, ...x, z: 3 } // error for 'z', no error for 'extra'
|
1
tests/cases/compiler/unicodeStringLiteral.ts
Normal file
1
tests/cases/compiler/unicodeStringLiteral.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
var ੳ = "Üਲĭ";
|
|
@ -11,9 +11,9 @@ var x: number = E1.A;
|
||||||
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
// Enum object type is anonymous with properties of the enum type and numeric indexer
|
||||||
var e = E1;
|
var e = E1;
|
||||||
var e: {
|
var e: {
|
||||||
readonly A: E1;
|
readonly A: E1.A;
|
||||||
readonly B: E1;
|
readonly B: E1.B;
|
||||||
readonly C: E1;
|
readonly C: E1.C;
|
||||||
readonly [n: number]: string;
|
readonly [n: number]: string;
|
||||||
};
|
};
|
||||||
var e: typeof E1;
|
var e: typeof E1;
|
||||||
|
|
80
tests/cases/conformance/enums/enumClassification.ts
Normal file
80
tests/cases/conformance/enums/enumClassification.ts
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
// @declaration: true
|
||||||
|
|
||||||
|
// An enum type where each member has no initializer or an initializer that specififes
|
||||||
|
// a numeric literal, a string literal, or a single identifier naming another member in
|
||||||
|
// the enum type is classified as a literal enum type. An enum type that doesn't adhere
|
||||||
|
// to this pattern is classified as a numeric enum type.
|
||||||
|
|
||||||
|
// Examples of literal enum types
|
||||||
|
|
||||||
|
enum E01 {
|
||||||
|
A
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E02 {
|
||||||
|
A = 123
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E03 {
|
||||||
|
A = "hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E04 {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E05 {
|
||||||
|
A,
|
||||||
|
B = 10,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E06 {
|
||||||
|
A = "one",
|
||||||
|
B = "two",
|
||||||
|
C = "three"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E07 {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
C = "hi",
|
||||||
|
D = 10,
|
||||||
|
E,
|
||||||
|
F = "bye"
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E08 {
|
||||||
|
A = 10,
|
||||||
|
B = "hello",
|
||||||
|
C = A,
|
||||||
|
D = B,
|
||||||
|
E = C,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with only constant members
|
||||||
|
|
||||||
|
enum E10 {}
|
||||||
|
|
||||||
|
enum E11 {
|
||||||
|
A = +0,
|
||||||
|
B,
|
||||||
|
C
|
||||||
|
}
|
||||||
|
|
||||||
|
enum E12 {
|
||||||
|
A = 1 << 0,
|
||||||
|
B = 1 << 1,
|
||||||
|
C = 1 << 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// Examples of numeric enum types with constant and computed members
|
||||||
|
|
||||||
|
enum E20 {
|
||||||
|
A = "foo".length,
|
||||||
|
B = A + 1,
|
||||||
|
C = +"123",
|
||||||
|
D = Math.sin(1)
|
||||||
|
}
|
|
@ -23,8 +23,17 @@ enum E10 {
|
||||||
|
|
||||||
// Enum with computed member intializer of other types
|
// Enum with computed member intializer of other types
|
||||||
enum E11 {
|
enum E11 {
|
||||||
A = '',
|
A = true,
|
||||||
B = new Date(),
|
B = new Date(),
|
||||||
C = window,
|
C = window,
|
||||||
D = {}
|
D = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enum with string valued member and computed member initializers
|
||||||
|
enum E12 {
|
||||||
|
A = '',
|
||||||
|
B = new Date(),
|
||||||
|
C = window,
|
||||||
|
D = {},
|
||||||
|
E = 1 + 1,
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
declare function all(a?: number, b?: number): void;
|
||||||
|
declare function weird(a?: number | string, b?: number | string): void;
|
||||||
|
declare function prefix(s: string, a?: number, b?: number): void;
|
||||||
|
declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void;
|
||||||
|
declare function normal(s: string): void;
|
||||||
|
declare function thunk(): string;
|
||||||
|
|
||||||
|
declare var ns: number[];
|
||||||
|
declare var mixed: (number | string)[];
|
||||||
|
declare var tuple: [number, string];
|
||||||
|
|
||||||
|
// good
|
||||||
|
all(...ns)
|
||||||
|
weird(...ns)
|
||||||
|
weird(...mixed)
|
||||||
|
weird(...tuple)
|
||||||
|
prefix("a", ...ns)
|
||||||
|
rest("d", ...ns)
|
||||||
|
|
||||||
|
|
||||||
|
// this covers the arguments case
|
||||||
|
normal("g", ...ns)
|
||||||
|
normal("h", ...mixed)
|
||||||
|
normal("i", ...tuple)
|
||||||
|
thunk(...ns)
|
||||||
|
thunk(...mixed)
|
||||||
|
thunk(...tuple)
|
||||||
|
|
||||||
|
// bad
|
||||||
|
all(...mixed)
|
||||||
|
all(...tuple)
|
||||||
|
prefix("b", ...mixed)
|
||||||
|
prefix("c", ...tuple)
|
||||||
|
rest("e", ...mixed)
|
||||||
|
rest("f", ...tuple)
|
||||||
|
prefix(...ns) // required parameters are required
|
||||||
|
prefix(...mixed)
|
||||||
|
prefix(...tuple)
|
16
tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx
Normal file
16
tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// @filename: file.tsx
|
||||||
|
// @jsx: preserve
|
||||||
|
// @noLib: true
|
||||||
|
// @libFiles: react.d.ts,lib.d.ts
|
||||||
|
|
||||||
|
import React = require('react');
|
||||||
|
|
||||||
|
export function makeP<P>(Ctor: React.ComponentClass<P>): React.ComponentClass<P> {
|
||||||
|
return class extends React.PureComponent<P, void> {
|
||||||
|
public render(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<Ctor {...this.props } />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
var a: YesNo;
|
||||||
|
var a: NoYes;
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
101
tests/cases/conformance/types/literal/stringEnumLiteralTypes2.ts
Normal file
101
tests/cases/conformance/types/literal/stringEnumLiteralTypes2.ts
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
// @strictNullChecks: true
|
||||||
|
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1() {
|
||||||
|
var a: YesNo;
|
||||||
|
var a: NoYes;
|
||||||
|
var a: Choice.Yes | Choice.No;
|
||||||
|
var a: Choice.No | Choice.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
b = a;
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Choice.Yes, b: YesNo) {
|
||||||
|
var x = a + b;
|
||||||
|
var y = a == b;
|
||||||
|
var y = a != b;
|
||||||
|
var y = a === b;
|
||||||
|
var y = a !== b;
|
||||||
|
var y = a > b;
|
||||||
|
var y = a < b;
|
||||||
|
var y = a >= b;
|
||||||
|
var y = a <= b;
|
||||||
|
var y = !b;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function g(x: Choice.Yes): string;
|
||||||
|
declare function g(x: Choice.No): boolean;
|
||||||
|
declare function g(x: Choice): number;
|
||||||
|
|
||||||
|
function f5(a: YesNo, b: UnknownYesNo, c: Choice) {
|
||||||
|
var z1 = g(Choice.Yes);
|
||||||
|
var z2 = g(Choice.No);
|
||||||
|
var z3 = g(a);
|
||||||
|
var z4 = g(b);
|
||||||
|
var z5 = g(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNever(x: never): never {
|
||||||
|
throw new Error("Unexpected value");
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo) {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Yes: return "true";
|
||||||
|
case Choice.No: return "false";
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo) {
|
||||||
|
if (x) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: UnknownYesNo) {
|
||||||
|
if (x === Choice.Yes) {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Item =
|
||||||
|
{ kind: Choice.Yes, a: string } |
|
||||||
|
{ kind: Choice.No, b: string };
|
||||||
|
|
||||||
|
function f20(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function f21(x: Item) {
|
||||||
|
switch (x.kind) {
|
||||||
|
case Choice.Yes: return x.a;
|
||||||
|
case Choice.No: return x.b;
|
||||||
|
}
|
||||||
|
return assertNever(x);
|
||||||
|
}
|
119
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts
Normal file
119
tests/cases/conformance/types/literal/stringEnumLiteralTypes3.ts
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
const enum Choice { Unknown = "", Yes = "yes", No = "no" };
|
||||||
|
|
||||||
|
type Yes = Choice.Yes;
|
||||||
|
type YesNo = Choice.Yes | Choice.No;
|
||||||
|
type NoYes = Choice.No | Choice.Yes;
|
||||||
|
type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No;
|
||||||
|
|
||||||
|
function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = a;
|
||||||
|
a = b;
|
||||||
|
a = c;
|
||||||
|
a = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f2(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
b = a;
|
||||||
|
b = b;
|
||||||
|
b = c;
|
||||||
|
b = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f3(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
c = a;
|
||||||
|
c = b;
|
||||||
|
c = c;
|
||||||
|
c = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f4(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
d = a;
|
||||||
|
d = b;
|
||||||
|
d = c;
|
||||||
|
d = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f5(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a = Choice.Unknown;
|
||||||
|
a = Choice.Yes;
|
||||||
|
a = Choice.No;
|
||||||
|
b = Choice.Unknown;
|
||||||
|
b = Choice.Yes;
|
||||||
|
b = Choice.No;
|
||||||
|
c = Choice.Unknown;
|
||||||
|
c = Choice.Yes;
|
||||||
|
c = Choice.No;
|
||||||
|
d = Choice.Unknown;
|
||||||
|
d = Choice.Yes;
|
||||||
|
d = Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f6(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === Choice.Unknown;
|
||||||
|
a === Choice.Yes;
|
||||||
|
a === Choice.No;
|
||||||
|
b === Choice.Unknown;
|
||||||
|
b === Choice.Yes;
|
||||||
|
b === Choice.No;
|
||||||
|
c === Choice.Unknown;
|
||||||
|
c === Choice.Yes;
|
||||||
|
c === Choice.No;
|
||||||
|
d === Choice.Unknown;
|
||||||
|
d === Choice.Yes;
|
||||||
|
d === Choice.No;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f7(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) {
|
||||||
|
a === a;
|
||||||
|
a === b;
|
||||||
|
a === c;
|
||||||
|
a === d;
|
||||||
|
b === a;
|
||||||
|
b === b;
|
||||||
|
b === c;
|
||||||
|
b === d;
|
||||||
|
c === a;
|
||||||
|
c === b;
|
||||||
|
c === c;
|
||||||
|
c === d;
|
||||||
|
d === a;
|
||||||
|
d === b;
|
||||||
|
d === c;
|
||||||
|
d === d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f10(x: Yes): Yes {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f11(x: YesNo): YesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f12(x: UnknownYesNo): UnknownYesNo {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f13(x: Choice): Choice {
|
||||||
|
switch (x) {
|
||||||
|
case Choice.Unknown: return x;
|
||||||
|
case Choice.Yes: return x;
|
||||||
|
case Choice.No: return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
/// <reference path='fourslash.ts' />
|
/// <reference path='fourslash.ts' />
|
||||||
|
|
||||||
//// interface I<X> {
|
//// interface I<X> {
|
||||||
//// [x: string]: X;
|
//// [Ƚ: string]: X;
|
||||||
//// }
|
//// }
|
||||||
////
|
////
|
||||||
//// class C implements I<number> {[| |]}
|
//// class C implements I<number> {[| |]}
|
||||||
|
|
||||||
verify.rangeAfterCodeFix(`
|
verify.rangeAfterCodeFix(`
|
||||||
[x: string]: number;
|
[Ƚ: string]: number;
|
||||||
`);
|
`);
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
//// abstract class C1 { }
|
//// abstract class C1 { }
|
||||||
//// abstract class C2 {
|
//// abstract class C2 {
|
||||||
//// abstract f1<T extends number>();
|
//// abstract fA<T extends number>();
|
||||||
//// }
|
//// }
|
||||||
//// interface I1 extends C1, C2 { }
|
//// interface I1 extends C1, C2 { }
|
||||||
//// class C3 implements I1 {[| |]}
|
//// class C3 implements I1 {[| |]}
|
||||||
|
|
||||||
verify.rangeAfterCodeFix(`f1<T extends number>(){
|
verify.rangeAfterCodeFix(`fA<T extends number>(){
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
`);
|
`);
|
|
@ -0,0 +1,16 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
|
||||||
|
//// type Either<T> = { val: T } | Error;
|
||||||
|
//// interface I {
|
||||||
|
//// x: Either<Either<string>>;
|
||||||
|
//// foo(x: Either<Either<string>>): void;
|
||||||
|
//// }
|
||||||
|
//// class C implements I {[| |]}
|
||||||
|
|
||||||
|
verify.rangeAfterCodeFix(`
|
||||||
|
x: Either<Either<string>>;
|
||||||
|
foo(x: Either<Either<string>>): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
|
||||||
|
//// type MyType = [string, number];
|
||||||
|
//// interface I { x: MyType; test(a: MyType): void; }
|
||||||
|
//// class C implements I {[| |]}
|
||||||
|
|
||||||
|
verify.rangeAfterCodeFix(`
|
||||||
|
x: [string, number];
|
||||||
|
test(a: [string, number]): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
`);
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue