merge master

This commit is contained in:
Dan Quirk
2015-07-09 18:16:21 -07:00
42 changed files with 864 additions and 190 deletions
+47 -53
View File
@@ -1948,7 +1948,19 @@ namespace ts {
writePunctuation(writer, SyntaxKind.ColonToken);
}
writeSpace(writer);
buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack);
let returnType: Type;
if (signature.typePredicate) {
writer.writeParameter(signature.typePredicate.parameterName);
writeSpace(writer);
writeKeyword(writer, SyntaxKind.IsKeyword);
writeSpace(writer);
returnType = signature.typePredicate.type;
}
else {
returnType = getReturnTypeOfSignature(signature);
}
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
}
function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
@@ -3305,7 +3317,7 @@ namespace ts {
let declarations: Declaration[] = [];
for (let prop of props) {
if (prop.declarations) {
declarations.push.apply(declarations, prop.declarations);
addRange(declarations, prop.declarations);
}
propTypes.push(getTypeOfSymbol(prop));
}
@@ -5490,7 +5502,7 @@ namespace ts {
}
}
else if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) ||
(target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral))) {
(target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) {
// If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members
if (isInProcess(source, target)) {
return;
@@ -7094,14 +7106,17 @@ namespace ts {
// Look up the value in the current scope
if (node.tagName.kind === SyntaxKind.Identifier) {
valueSymbol = getResolvedSymbol(<Identifier>node.tagName);
let tag = <Identifier>node.tagName;
let sym = getResolvedSymbol(tag);
valueSymbol = sym.exportSymbol || sym;
}
else {
valueSymbol = checkQualifiedName(<QualifiedName>node.tagName).symbol;
}
if (valueSymbol !== unknownSymbol) {
if (valueSymbol && valueSymbol !== unknownSymbol) {
links.jsxFlags |= JsxFlags.ClassElement;
getSymbolLinks(valueSymbol).referenced = true;
}
return valueSymbol || unknownSymbol;
@@ -7310,15 +7325,6 @@ namespace ts {
let targetAttributesType = getJsxElementAttributesType(node);
if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) {
if (node.tagName.kind === SyntaxKind.Identifier) {
checkIdentifier(<Identifier>node.tagName);
}
else {
checkQualifiedName(<QualifiedName>node.tagName);
}
}
let nameTable: Map<boolean> = {};
// Process this array in right-to-left order so we know which
// attributes (mostly from spreads) are being overwritten and
@@ -8006,7 +8012,8 @@ namespace ts {
return args;
}
/**
/**
* Returns the effective argument count for a node that works like a function invocation.
* If 'node' is a Decorator, the number of arguments is derived from the decoration
* target and the signature:
@@ -8086,8 +8093,8 @@ namespace ts {
// fall-through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
// For a property or method decorator, the `target` is the
@@ -8131,13 +8138,13 @@ namespace ts {
return anyType;
}
// For a non-constructor parameter decorator, the `propertyKey` will be either
// a string or a symbol, based on the name of the parameter's containing method.
// fall-through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
// For a non-constructor parameter decorator, the `propertyKey` will be either
// a string or a symbol, based on the name of the parameter's containing method.
// fall-through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
// The `propertyKey` for a property or method decorator will be a
@@ -11452,32 +11459,19 @@ namespace ts {
forEach(node.declarationList.declarations, checkSourceElement);
}
function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node: Node) {
if (node.modifiers) {
if (inBlockOrObjectLiteralExpression(node)) {
if (isAsyncFunctionLike(node)) {
if (node.modifiers.length > 1) {
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
}
}
else {
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) {
// We only disallow modifier on a method declaration if it is a property of object-literal-expression
if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){
if (isAsyncFunctionLike(node)) {
if (node.modifiers.length > 1) {
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
}
}
}
}
function inBlockOrObjectLiteralExpression(node: Node) {
while (node) {
if (node.kind === SyntaxKind.Block || node.kind === SyntaxKind.ObjectLiteralExpression) {
return true;
else {
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
}
node = node.parent;
}
return false;
}
}
function checkExpressionStatement(node: ExpressionStatement) {
// Grammar checking
@@ -14735,10 +14729,10 @@ namespace ts {
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
}
function checkGrammarForOmittedArgument(node: CallExpression, arguments: NodeArray<Expression>): boolean {
if (arguments) {
function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray<Expression>): boolean {
if (args) {
let sourceFile = getSourceFileOfNode(node);
for (let arg of arguments) {
for (let arg of args) {
if (arg.kind === SyntaxKind.OmittedExpression) {
return grammarErrorAtPos(sourceFile, arg.pos, 0, Diagnostics.Argument_expression_expected);
}
@@ -14746,9 +14740,9 @@ namespace ts {
}
}
function checkGrammarArguments(node: CallExpression, arguments: NodeArray<Expression>): boolean {
return checkGrammarForDisallowedTrailingComma(arguments) ||
checkGrammarForOmittedArgument(node, arguments);
function checkGrammarArguments(node: CallExpression, args: NodeArray<Expression>): boolean {
return checkGrammarForDisallowedTrailingComma(args) ||
checkGrammarForOmittedArgument(node, args);
}
function checkGrammarHeritageClause(node: HeritageClause): boolean {
@@ -15034,7 +15028,7 @@ namespace ts {
}
function checkGrammarMethod(node: MethodDeclaration) {
if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) ||
if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) ||
checkGrammarFunctionLikeDeclaration(node) ||
checkGrammarForGenerator(node)) {
return true;
+21 -13
View File
@@ -353,6 +353,21 @@ namespace ts {
return emitEntityName(<Identifier>type);
case SyntaxKind.QualifiedName:
return emitEntityName(<QualifiedName>type);
case SyntaxKind.TypePredicate:
return emitTypePredicate(<TypePredicateNode>type);
}
function writeEntityName(entityName: EntityName | Expression) {
if (entityName.kind === SyntaxKind.Identifier) {
writeTextOfNode(currentSourceFile, entityName);
}
else {
let left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
let right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
writeEntityName(left);
write(".");
writeTextOfNode(currentSourceFile, right);
}
}
function emitEntityName(entityName: EntityName | PropertyAccessExpression) {
@@ -362,19 +377,6 @@ namespace ts {
handleSymbolAccessibilityError(visibilityResult);
writeEntityName(entityName);
function writeEntityName(entityName: EntityName | Expression) {
if (entityName.kind === SyntaxKind.Identifier) {
writeTextOfNode(currentSourceFile, entityName);
}
else {
let left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
let right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
writeEntityName(left);
write(".");
writeTextOfNode(currentSourceFile, right);
}
}
}
function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
@@ -398,6 +400,12 @@ namespace ts {
}
}
function emitTypePredicate(type: TypePredicateNode) {
writeTextOfNode(currentSourceFile, type.parameterName);
write(" is ");
emitType(type.type);
}
function emitTypeQuery(type: TypeQueryNode) {
write("typeof ");
emitEntityName(type.exprName);
+4 -4
View File
@@ -35,9 +35,9 @@ class FourSlashRunner extends RunnerBase {
this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false });
}
this.tests.forEach((fn: string) => {
describe(fn, () => {
fn = ts.normalizeSlashes(fn);
this.tests.forEach((fn: string) => {
describe(fn, () => {
fn = ts.normalizeSlashes(fn);
var justName = fn.replace(/^.*[\\\/]/, '');
// Convert to relative path
@@ -45,7 +45,7 @@ class FourSlashRunner extends RunnerBase {
if (testIndex >= 0) fn = fn.substr(testIndex);
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => {
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
});
}
+16 -13
View File
@@ -2254,12 +2254,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* @param elementId String that specifies the ID value. Case-insensitive.
*/
getElementById(elementId: string): HTMLElement;
getElementsByClassName(classNames: string): NodeList;
getElementsByClassName(classNames: string): NodeListOf<Element>;
/**
* Gets a collection of objects based on the value of the NAME or ID attribute.
* @param elementName Gets a collection of objects based on the value of the NAME or ID attribute.
*/
getElementsByName(elementName: string): NodeList;
getElementsByName(elementName: string): NodeListOf<Element>;
/**
* Retrieves a collection of objects based on the specified element name.
* @param name Specifies the name of an element.
@@ -2437,8 +2437,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
getElementsByTagName(tagname: "wbr"): NodeListOf<HTMLElement>;
getElementsByTagName(tagname: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
getElementsByTagName(tagname: "xmp"): NodeListOf<HTMLBlockElement>;
getElementsByTagName(tagname: string): NodeList;
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
getElementsByTagName(tagname: string): NodeListOf<Element>;
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
/**
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
*/
@@ -2711,6 +2711,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
scrollTop: number;
scrollWidth: number;
tagName: string;
id: string;
className: string;
getAttribute(name?: string): string;
getAttributeNS(namespaceURI: string, localName: string): string;
getAttributeNode(name: string): Attr;
@@ -2890,8 +2892,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
getElementsByTagName(name: "wbr"): NodeListOf<HTMLElement>;
getElementsByTagName(name: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
getElementsByTagName(name: "xmp"): NodeListOf<HTMLBlockElement>;
getElementsByTagName(name: string): NodeList;
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
getElementsByTagName(name: string): NodeListOf<Element>;
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
hasAttribute(name: string): boolean;
hasAttributeNS(namespaceURI: string, localName: string): boolean;
msGetRegionContent(): MSRangeCollection;
@@ -3072,7 +3074,7 @@ interface FormData {
declare var FormData: {
prototype: FormData;
new(): FormData;
new (form?: HTMLFormElement): FormData;
}
interface GainNode extends AudioNode {
@@ -3809,14 +3811,12 @@ declare var HTMLDocument: {
interface HTMLElement extends Element {
accessKey: string;
children: HTMLCollection;
className: string;
contentEditable: string;
dataset: DOMStringMap;
dir: string;
draggable: boolean;
hidden: boolean;
hideFocus: boolean;
id: string;
innerHTML: string;
innerText: string;
isContentEditable: boolean;
@@ -3903,7 +3903,7 @@ interface HTMLElement extends Element {
contains(child: HTMLElement): boolean;
dragDrop(): boolean;
focus(): void;
getElementsByClassName(classNames: string): NodeList;
getElementsByClassName(classNames: string): NodeListOf<Element>;
insertAdjacentElement(position: string, insertedElement: Element): Element;
insertAdjacentHTML(where: string, html: string): void;
insertAdjacentText(where: string, text: string): void;
@@ -8715,6 +8715,7 @@ declare var SVGDescElement: {
interface SVGElement extends Element {
id: string;
className: any;
onclick: (ev: MouseEvent) => any;
ondblclick: (ev: MouseEvent) => any;
onfocusin: (ev: FocusEvent) => any;
@@ -11984,6 +11985,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
toolbar: BarProp;
top: Window;
window: Window;
URL: URL;
alert(message?: any): void;
blur(): void;
cancelAnimationFrame(handle: number): void;
@@ -12487,7 +12489,7 @@ interface NavigatorStorageUtils {
interface NodeSelector {
querySelector(selectors: string): Element;
querySelectorAll(selectors: string): NodeList;
querySelectorAll(selectors: string): NodeListOf<Element>;
}
interface RandomSource {
@@ -12535,7 +12537,7 @@ interface SVGLocatable {
}
interface SVGStylable {
className: SVGAnimatedString;
className: any;
style: CSSStyleDeclaration;
}
@@ -12622,7 +12624,7 @@ interface EventListenerObject {
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
(event: Event | string, source?: string, fileno?: number, columnNumber?: number): void;
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
interface PositionCallback {
(position: Position): void;
@@ -12798,6 +12800,7 @@ declare var styleMedia: StyleMedia;
declare var toolbar: BarProp;
declare var top: Window;
declare var window: Window;
declare var URL: URL;
declare function alert(message?: any): void;
declare function blur(): void;
declare function cancelAnimationFrame(handle: number): void;
+2 -2
View File
@@ -228,7 +228,7 @@ namespace ts.NavigationBar {
function merge(target: ts.NavigationBarItem, source: ts.NavigationBarItem) {
// First, add any spans in the source to the target.
target.spans.push.apply(target.spans, source.spans);
addRange(target.spans, source.spans);
if (source.childItems) {
if (!target.childItems) {
@@ -465,7 +465,7 @@ namespace ts.NavigationBar {
// are not properties will be filtered out later by createChildItem.
let nodes: Node[] = removeDynamicallyNamedProperties(node);
if (constructor) {
nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
addRange(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
}
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
+11 -11
View File
@@ -345,7 +345,7 @@ namespace ts {
ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), jsDocCommentTextRange => {
let cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
if (cleanedParamJsDocComment) {
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment);
addRange(jsDocCommentParts, cleanedParamJsDocComment);
}
});
}
@@ -365,7 +365,7 @@ namespace ts {
declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => {
let cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
if (cleanedJsDocComment) {
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment);
addRange(jsDocCommentParts, cleanedJsDocComment);
}
});
}
@@ -3854,7 +3854,7 @@ namespace ts {
displayParts.push(spacePart());
}
if (!(type.flags & TypeFlags.Anonymous)) {
displayParts.push.apply(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
}
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
break;
@@ -3915,7 +3915,7 @@ namespace ts {
displayParts.push(spacePart());
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
addRange(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
}
if (symbolFlags & SymbolFlags.Enum) {
addNewLineIfDisplayPartsExist();
@@ -3961,7 +3961,7 @@ namespace ts {
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
}
}
if (symbolFlags & SymbolFlags.EnumMember) {
@@ -4022,10 +4022,10 @@ namespace ts {
let typeParameterParts = mapToDisplayParts(writer => {
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(<TypeParameter>type, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
addRange(displayParts, typeParameterParts);
}
else {
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
}
}
else if (symbolFlags & SymbolFlags.Function ||
@@ -4059,7 +4059,7 @@ namespace ts {
function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) {
let fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing);
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
addRange(displayParts, fullSymbolDisplayParts);
}
function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) {
@@ -4089,7 +4089,7 @@ namespace ts {
}
function addSignatureDisplayParts(signature: Signature, allSignatures: Signature[], flags?: TypeFormatFlags) {
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
if (allSignatures.length > 1) {
displayParts.push(spacePart());
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
@@ -4106,7 +4106,7 @@ namespace ts {
let typeParameterParts = mapToDisplayParts(writer => {
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
});
displayParts.push.apply(displayParts, typeParameterParts);
addRange(displayParts, typeParameterParts);
}
}
@@ -5620,7 +5620,7 @@ namespace ts {
// type to the search set
if (isNameOfPropertyAssignment(location)) {
forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => {
result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
addRange(result, typeChecker.getRootSymbols(contextualSymbol));
});
/* Because in short-hand property assignment, location has two meaning : property name and as value of the property
+4 -4
View File
@@ -550,7 +550,7 @@ namespace ts.SignatureHelp {
let suffixDisplayParts: SymbolDisplayPart[] = [];
if (callTargetDisplayParts) {
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
addRange(prefixDisplayParts, callTargetDisplayParts);
}
if (isTypeParameterList) {
@@ -560,12 +560,12 @@ namespace ts.SignatureHelp {
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
let parameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
addRange(suffixDisplayParts, parameterParts);
}
else {
let typeParameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
addRange(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
let parameters = candidateSignature.parameters;
@@ -575,7 +575,7 @@ namespace ts.SignatureHelp {
let returnTypeParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
addRange(suffixDisplayParts, returnTypeParts);
return {
isVariadic: candidateSignature.hasRestParameter,
@@ -26,6 +26,19 @@ export function fooWithSingleOverload(a: any) {
return a;
}
export function fooWithTypePredicate(a: any): a is number {
return true;
}
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
return true;
}
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
return true;
}
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
return true;
}
/** This comment should appear for nonExportedFoo*/
function nonExportedFoo() {
}
@@ -92,6 +105,26 @@ function fooWithSingleOverload(a) {
return a;
}
exports.fooWithSingleOverload = fooWithSingleOverload;
function fooWithTypePredicate(a) {
return true;
}
exports.fooWithTypePredicate = fooWithTypePredicate;
function fooWithTypePredicateAndMulitpleParams(a, b, c) {
return true;
}
exports.fooWithTypePredicateAndMulitpleParams = fooWithTypePredicateAndMulitpleParams;
function fooWithTypeTypePredicateAndGeneric(a) {
return true;
}
exports.fooWithTypeTypePredicateAndGeneric = fooWithTypeTypePredicateAndGeneric;
function fooWithTypeTypePredicateAndRestParam(a) {
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
return true;
}
exports.fooWithTypeTypePredicateAndRestParam = fooWithTypeTypePredicateAndRestParam;
/** This comment should appear for nonExportedFoo*/
function nonExportedFoo() {
}
@@ -144,6 +177,10 @@ export declare function fooWithRestParameters(a: string, ...rests: string[]): st
export declare function fooWithOverloads(a: string): string;
export declare function fooWithOverloads(a: number): number;
export declare function fooWithSingleOverload(a: string): string;
export declare function fooWithTypePredicate(a: any): a is number;
export declare function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number;
export declare function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T;
export declare function fooWithTypeTypePredicateAndRestParam(a: any, ...rest: any[]): a is number;
//// [declFileFunctions_1.d.ts]
/** This comment should appear for foo*/
declare function globalfoo(): void;
@@ -57,49 +57,83 @@ export function fooWithSingleOverload(a: any) {
>a : Symbol(a, Decl(declFileFunctions_0.ts, 21, 38))
}
export function fooWithTypePredicate(a: any): a is number {
>fooWithTypePredicate : Symbol(fooWithTypePredicate, Decl(declFileFunctions_0.ts, 23, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37))
return true;
}
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
>fooWithTypePredicateAndMulitpleParams : Symbol(fooWithTypePredicateAndMulitpleParams, Decl(declFileFunctions_0.ts, 27, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
>b : Symbol(b, Decl(declFileFunctions_0.ts, 28, 61))
>c : Symbol(c, Decl(declFileFunctions_0.ts, 28, 69))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
return true;
}
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
>fooWithTypeTypePredicateAndGeneric : Symbol(fooWithTypeTypePredicateAndGeneric, Decl(declFileFunctions_0.ts, 30, 1))
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
return true;
}
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
>fooWithTypeTypePredicateAndRestParam : Symbol(fooWithTypeTypePredicateAndRestParam, Decl(declFileFunctions_0.ts, 33, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
>rest : Symbol(rest, Decl(declFileFunctions_0.ts, 34, 60))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
return true;
}
/** This comment should appear for nonExportedFoo*/
function nonExportedFoo() {
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 23, 1))
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 36, 1))
}
/** This is comment for function signature*/
function nonExportedFooWithParameters(/** this is comment about a*/a: string,
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 27, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38))
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 40, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
/** this is comment for b*/
b: number) {
>b : Symbol(b, Decl(declFileFunctions_0.ts, 29, 77))
>b : Symbol(b, Decl(declFileFunctions_0.ts, 42, 77))
var d = a;
>d : Symbol(d, Decl(declFileFunctions_0.ts, 32, 7))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38))
>d : Symbol(d, Decl(declFileFunctions_0.ts, 45, 7))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
}
function nonExportedFooWithRestParameters(a: string, ...rests: string[]) {
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 33, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42))
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52))
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 46, 1))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
return a + rests.join("");
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
>rests.join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52))
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
>join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
}
function nonExportedFooWithOverloads(a: string): string;
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 38, 37))
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 51, 37))
function nonExportedFooWithOverloads(a: number): number;
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 39, 37))
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 52, 37))
function nonExportedFooWithOverloads(a: any): any {
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37))
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
return a;
>a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37))
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
}
=== tests/cases/compiler/declFileFunctions_1.ts ===
@@ -60,6 +60,44 @@ export function fooWithSingleOverload(a: any) {
>a : any
}
export function fooWithTypePredicate(a: any): a is number {
>fooWithTypePredicate : (a: any) => a is number
>a : any
>a : any
return true;
>true : boolean
}
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
>fooWithTypePredicateAndMulitpleParams : (a: any, b: any, c: any) => a is number
>a : any
>b : any
>c : any
>a : any
return true;
>true : boolean
}
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
>fooWithTypeTypePredicateAndGeneric : <T>(a: any) => a is T
>T : T
>a : any
>a : any
>T : T
return true;
>true : boolean
}
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
>fooWithTypeTypePredicateAndRestParam : (a: any, ...rest: any[]) => a is number
>a : any
>rest : any[]
>a : any
return true;
>true : boolean
}
/** This comment should appear for nonExportedFoo*/
function nonExportedFoo() {
>nonExportedFoo : () => void
+2 -2
View File
@@ -5,9 +5,9 @@ var maybeArray: number | number[];
if (Array.isArray(maybeArray)) {
>Array.isArray(maybeArray) : boolean
>Array.isArray : (arg: any) => boolean
>Array.isArray : (arg: any) => arg is any[]
>Array : ArrayConstructor
>isArray : (arg: any) => boolean
>isArray : (arg: any) => arg is any[]
>maybeArray : number | number[]
maybeArray.length; // OK
@@ -0,0 +1,25 @@
//// [modifierOnClassDeclarationMemberInFunction.ts]
function f() {
class C {
public baz = 1;
static foo() { }
public bar() { }
}
}
//// [modifierOnClassDeclarationMemberInFunction.js]
function f() {
var C = (function () {
function C() {
this.baz = 1;
}
C.foo = function () { };
C.prototype.bar = function () { };
return C;
})();
}
//// [modifierOnClassDeclarationMemberInFunction.d.ts]
declare function f(): void;
@@ -0,0 +1,18 @@
=== tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts ===
function f() {
>f : Symbol(f, Decl(modifierOnClassDeclarationMemberInFunction.ts, 0, 0))
class C {
>C : Symbol(C, Decl(modifierOnClassDeclarationMemberInFunction.ts, 1, 14))
public baz = 1;
>baz : Symbol(baz, Decl(modifierOnClassDeclarationMemberInFunction.ts, 2, 13))
static foo() { }
>foo : Symbol(C.foo, Decl(modifierOnClassDeclarationMemberInFunction.ts, 3, 23))
public bar() { }
>bar : Symbol(bar, Decl(modifierOnClassDeclarationMemberInFunction.ts, 4, 24))
}
}
@@ -0,0 +1,19 @@
=== tests/cases/conformance/classes/classDeclarations/modifierOnClassDeclarationMemberInFunction.ts ===
function f() {
>f : () => void
class C {
>C : C
public baz = 1;
>baz : number
>1 : number
static foo() { }
>foo : () => void
public bar() { }
>bar : () => void
}
}
@@ -0,0 +1,25 @@
//// [modifierOnClassExpressionMemberInFunction.ts]
function g() {
var x = class C {
public prop1 = 1;
private foo() { }
static prop2 = 43;
}
}
//// [modifierOnClassExpressionMemberInFunction.js]
function g() {
var x = (function () {
function C() {
this.prop1 = 1;
}
C.prototype.foo = function () { };
C.prop2 = 43;
return C;
})();
}
//// [modifierOnClassExpressionMemberInFunction.d.ts]
declare function g(): void;
@@ -0,0 +1,19 @@
=== tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts ===
function g() {
>g : Symbol(g, Decl(modifierOnClassExpressionMemberInFunction.ts, 0, 0))
var x = class C {
>x : Symbol(x, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 7))
>C : Symbol(C, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 11))
public prop1 = 1;
>prop1 : Symbol(C.prop1, Decl(modifierOnClassExpressionMemberInFunction.ts, 2, 21))
private foo() { }
>foo : Symbol(C.foo, Decl(modifierOnClassExpressionMemberInFunction.ts, 3, 25))
static prop2 = 43;
>prop2 : Symbol(C.prop2, Decl(modifierOnClassExpressionMemberInFunction.ts, 4, 25))
}
}
@@ -0,0 +1,22 @@
=== tests/cases/conformance/classes/classExpressions/modifierOnClassExpressionMemberInFunction.ts ===
function g() {
>g : () => void
var x = class C {
>x : typeof C
>class C { public prop1 = 1; private foo() { } static prop2 = 43; } : typeof C
>C : typeof C
public prop1 = 1;
>prop1 : number
>1 : number
private foo() { }
>foo : () => void
static prop2 = 43;
>prop2 : number
>43 : number
}
}
@@ -0,0 +1,31 @@
tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty {
props;
}
}
interface Props {
foo: string;
}
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
export class MyComponent {
render() {
}
props: { foo: string; }
}
<MyComponent foo="bar" />; // ok
<MyComponent foo={0} />; // should be an error
~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -0,0 +1,42 @@
//// [tests/cases/conformance/jsx/tsxAttributeResolution9.tsx] ////
//// [react.d.ts]
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty {
props;
}
}
interface Props {
foo: string;
}
//// [file.tsx]
export class MyComponent {
render() {
}
props: { foo: string; }
}
<MyComponent foo="bar" />; // ok
<MyComponent foo={0} />; // should be an error
//// [file.jsx]
define(["require", "exports"], function (require, exports) {
var MyComponent = (function () {
function MyComponent() {
}
MyComponent.prototype.render = function () {
};
return MyComponent;
})();
exports.MyComponent = MyComponent;
<MyComponent foo="bar"/>; // ok
<MyComponent foo={0}/>; // should be an error
});
@@ -0,0 +1,47 @@
=== tests/cases/conformance/jsx/react.d.ts ===
declare module JSX {
>JSX : Symbol(JSX, Decl(react.d.ts, 0, 0))
interface Element { }
>Element : Symbol(Element, Decl(react.d.ts, 1, 20))
interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react.d.ts, 2, 22))
}
interface ElementAttributesProperty {
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(react.d.ts, 4, 2))
props;
>props : Symbol(props, Decl(react.d.ts, 5, 38))
}
}
interface Props {
>Props : Symbol(Props, Decl(react.d.ts, 8, 1))
foo: string;
>foo : Symbol(foo, Decl(react.d.ts, 10, 17))
}
=== tests/cases/conformance/jsx/file.tsx ===
export class MyComponent {
>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0))
render() {
>render : Symbol(render, Decl(file.tsx, 0, 26))
}
props: { foo: string; }
>props : Symbol(props, Decl(file.tsx, 2, 3))
>foo : Symbol(foo, Decl(file.tsx, 4, 10))
}
<MyComponent foo="bar" />; // ok
>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0))
>foo : Symbol(unknown)
<MyComponent foo={0} />; // should be an error
>MyComponent : Symbol(MyComponent, Decl(file.tsx, 0, 0))
>foo : Symbol(unknown)
@@ -0,0 +1,49 @@
=== tests/cases/conformance/jsx/react.d.ts ===
declare module JSX {
>JSX : any
interface Element { }
>Element : Element
interface IntrinsicElements {
>IntrinsicElements : IntrinsicElements
}
interface ElementAttributesProperty {
>ElementAttributesProperty : ElementAttributesProperty
props;
>props : any
}
}
interface Props {
>Props : Props
foo: string;
>foo : string
}
=== tests/cases/conformance/jsx/file.tsx ===
export class MyComponent {
>MyComponent : MyComponent
render() {
>render : () => void
}
props: { foo: string; }
>props : { foo: string; }
>foo : string
}
<MyComponent foo="bar" />; // ok
><MyComponent foo="bar" /> : JSX.Element
>MyComponent : typeof MyComponent
>foo : any
<MyComponent foo={0} />; // should be an error
><MyComponent foo={0} /> : JSX.Element
>MyComponent : typeof MyComponent
>foo : any
@@ -0,0 +1,22 @@
//// [typeArgumentInferenceWithClassExpression1.ts]
function foo<T>(x = class { static prop: T }): T {
return undefined;
}
foo(class { static prop = "hello" }).length;
//// [typeArgumentInferenceWithClassExpression1.js]
function foo(x) {
if (x === void 0) { x = (function () {
function class_1() {
}
return class_1;
})(); }
return undefined;
}
foo((function () {
function class_2() {
}
class_2.prop = "hello";
return class_2;
})()).length;
@@ -0,0 +1,19 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts ===
function foo<T>(x = class { static prop: T }): T {
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 0))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13))
>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 16))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 27))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 13))
return undefined;
>undefined : Symbol(undefined)
}
foo(class { static prop = "hello" }).length;
>foo(class { static prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression1.ts, 0, 0))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression1.ts, 4, 11))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
@@ -0,0 +1,23 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression1.ts ===
function foo<T>(x = class { static prop: T }): T {
>foo : <T>(x?: typeof (Anonymous class)) => T
>T : T
>x : typeof (Anonymous class)
>class { static prop: T } : typeof (Anonymous class)
>prop : T
>T : T
>T : T
return undefined;
>undefined : undefined
}
foo(class { static prop = "hello" }).length;
>foo(class { static prop = "hello" }).length : number
>foo(class { static prop = "hello" }) : string
>foo : <T>(x?: typeof (Anonymous class)) => T
>class { static prop = "hello" } : typeof (Anonymous class)
>prop : string
>"hello" : string
>length : number
@@ -0,0 +1,16 @@
tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts(6,5): error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'.
Type '(Anonymous class)' is not assignable to type 'foo<{}>.'.
Property 'prop' is missing in type '(Anonymous class)'.
==== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts (1 errors) ====
function foo<T>(x = class { prop: T }): T {
return undefined;
}
// Should not infer string because it is a static property
foo(class { static prop = "hello" }).length;
~~~~~
!!! error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'.
!!! error TS2345: Type '(Anonymous class)' is not assignable to type 'foo<{}>.'.
!!! error TS2345: Property 'prop' is missing in type '(Anonymous class)'.
@@ -0,0 +1,24 @@
//// [typeArgumentInferenceWithClassExpression2.ts]
function foo<T>(x = class { prop: T }): T {
return undefined;
}
// Should not infer string because it is a static property
foo(class { static prop = "hello" }).length;
//// [typeArgumentInferenceWithClassExpression2.js]
function foo(x) {
if (x === void 0) { x = (function () {
function class_1() {
}
return class_1;
})(); }
return undefined;
}
// Should not infer string because it is a static property
foo((function () {
function class_2() {
}
class_2.prop = "hello";
return class_2;
})()).length;
@@ -0,0 +1,22 @@
//// [typeArgumentInferenceWithClassExpression3.ts]
function foo<T>(x = class { prop: T }): T {
return undefined;
}
foo(class { prop = "hello" }).length;
//// [typeArgumentInferenceWithClassExpression3.js]
function foo(x) {
if (x === void 0) { x = (function () {
function class_1() {
}
return class_1;
})(); }
return undefined;
}
foo((function () {
function class_2() {
this.prop = "hello";
}
return class_2;
})()).length;
@@ -0,0 +1,19 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts ===
function foo<T>(x = class { prop: T }): T {
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 0))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13))
>x : Symbol(x, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 16))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 27))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13))
>T : Symbol(T, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 13))
return undefined;
>undefined : Symbol(undefined)
}
foo(class { prop = "hello" }).length;
>foo(class { prop = "hello" }).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
>foo : Symbol(foo, Decl(typeArgumentInferenceWithClassExpression3.ts, 0, 0))
>prop : Symbol((Anonymous class).prop, Decl(typeArgumentInferenceWithClassExpression3.ts, 4, 11))
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
@@ -0,0 +1,23 @@
=== tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression3.ts ===
function foo<T>(x = class { prop: T }): T {
>foo : <T>(x?: typeof (Anonymous class)) => T
>T : T
>x : typeof (Anonymous class)
>class { prop: T } : typeof (Anonymous class)
>prop : T
>T : T
>T : T
return undefined;
>undefined : undefined
}
foo(class { prop = "hello" }).length;
>foo(class { prop = "hello" }).length : number
>foo(class { prop = "hello" }) : string
>foo : <T>(x?: typeof (Anonymous class)) => T
>class { prop = "hello" } : typeof (Anonymous class)
>prop : string
>"hello" : string
>length : number
@@ -23,19 +23,19 @@ class C extends A {
}
declare function isA(p1: any): p1 is A;
>isA : (p1: any) => boolean
>isA : (p1: any) => p1 is A
>p1 : any
>p1 : any
>A : A
declare function isB(p1: any): p1 is B;
>isB : (p1: any) => boolean
>isB : (p1: any) => p1 is B
>p1 : any
>p1 : any
>B : B
declare function isC(p1: any): p1 is C;
>isC : (p1: any) => boolean
>isC : (p1: any) => p1 is C
>p1 : any
>p1 : any
>C : C
@@ -55,7 +55,7 @@ var b: B;
// Basic
if (isC(a)) {
>isC(a) : boolean
>isC : (p1: any) => boolean
>isC : (p1: any) => p1 is C
>a : A
a.propC;
@@ -71,7 +71,7 @@ var subType: C;
if(isA(subType)) {
>isA(subType) : boolean
>isA : (p1: any) => boolean
>isA : (p1: any) => p1 is A
>subType : C
subType.propC;
@@ -88,7 +88,7 @@ var union: A | B;
if(isA(union)) {
>isA(union) : boolean
>isA : (p1: any) => boolean
>isA : (p1: any) => p1 is A
>union : A | B
union.propA;
@@ -111,7 +111,7 @@ interface I1 {
// The parameter index and argument index for the type guard target is matching.
// The type predicate type is assignable to the parameter type.
declare function isC_multipleParams(p1, p2): p1 is C;
>isC_multipleParams : (p1: any, p2: any) => boolean
>isC_multipleParams : (p1: any, p2: any) => p1 is C
>p1 : any
>p2 : any
>p1 : any
@@ -119,7 +119,7 @@ declare function isC_multipleParams(p1, p2): p1 is C;
if (isC_multipleParams(a, 0)) {
>isC_multipleParams(a, 0) : boolean
>isC_multipleParams : (p1: any, p2: any) => boolean
>isC_multipleParams : (p1: any, p2: any) => p1 is C
>a : A
>0 : number
@@ -131,10 +131,10 @@ if (isC_multipleParams(a, 0)) {
// Methods
var obj: {
>obj : { func1(p1: A): boolean; }
>obj : { func1(p1: A): p1 is C; }
func1(p1: A): p1 is C;
>func1 : (p1: A) => boolean
>func1 : (p1: A) => p1 is C
>p1 : A
>A : A
>p1 : any
@@ -144,7 +144,7 @@ class D {
>D : D
method1(p1: A): p1 is C {
>method1 : (p1: A) => boolean
>method1 : (p1: A) => p1 is C
>p1 : A
>A : A
>p1 : any
@@ -157,8 +157,8 @@ class D {
// Arrow function
let f1 = (p1: A): p1 is C => false;
>f1 : (p1: A) => boolean
>(p1: A): p1 is C => false : (p1: A) => boolean
>f1 : (p1: A) => p1 is C
>(p1: A): p1 is C => false : (p1: A) => p1 is C
>p1 : A
>A : A
>p1 : any
@@ -167,8 +167,8 @@ let f1 = (p1: A): p1 is C => false;
// Function type
declare function f2(p1: (p1: A) => p1 is C);
>f2 : (p1: (p1: A) => boolean) => any
>p1 : (p1: A) => boolean
>f2 : (p1: (p1: A) => p1 is C) => any
>p1 : (p1: A) => p1 is C
>p1 : A
>A : A
>p1 : any
@@ -177,8 +177,8 @@ declare function f2(p1: (p1: A) => p1 is C);
// Function expressions
f2(function(p1: A): p1 is C {
>f2(function(p1: A): p1 is C { return true;}) : any
>f2 : (p1: (p1: A) => boolean) => any
>function(p1: A): p1 is C { return true;} : (p1: A) => boolean
>f2 : (p1: (p1: A) => p1 is C) => any
>function(p1: A): p1 is C { return true;} : (p1: A) => p1 is C
>p1 : A
>A : A
>p1 : any
@@ -198,21 +198,21 @@ acceptingBoolean(isA(a));
>acceptingBoolean(isA(a)) : any
>acceptingBoolean : (a: boolean) => any
>isA(a) : boolean
>isA : (p1: any) => boolean
>isA : (p1: any) => p1 is A
>a : A
// Type predicates with different parameter name.
declare function acceptingTypeGuardFunction(p1: (item) => item is A);
>acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any
>p1 : (item: any) => boolean
>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any
>p1 : (item: any) => item is A
>item : any
>item : any
>A : A
acceptingTypeGuardFunction(isA);
>acceptingTypeGuardFunction(isA) : any
>acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any
>isA : (p1: any) => boolean
>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any
>isA : (p1: any) => p1 is A
// Binary expressions
let union2: C | B;
@@ -225,7 +225,7 @@ let union3: boolean | B = isA(union2) || union2;
>B : B
>isA(union2) || union2 : boolean | B
>isA(union2) : boolean
>isA : (p1: any) => boolean
>isA : (p1: any) => p1 is A
>union2 : B | C
>union2 : B
@@ -12,15 +12,15 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56)
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'.
Type predicate 'p1 is C' is not assignable to 'p1 is B'.
Type 'C' is not assignable to type 'B'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'.
Signature '(p1: any, p2: any): boolean' must have a type predicate.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
Type predicate 'p2 is A' is not assignable to 'p1 is A'.
Parameter 'p2' is not in the same position as parameter 'p1'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
@@ -141,7 +141,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
declare function acceptingDifferentSignatureTypeGuardFunction(p1: (p1) => p1 is B);
acceptingDifferentSignatureTypeGuardFunction(isC);
~~~
!!! error TS2345: Argument of type '(p1: any) => boolean' is not assignable to parameter of type '(p1: any) => boolean'.
!!! error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'.
!!! error TS2345: Type predicate 'p1 is C' is not assignable to 'p1 is B'.
!!! error TS2345: Type 'C' is not assignable to type 'B'.
@@ -149,7 +149,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
var assign1: (p1, p2) => p1 is A;
assign1 = function(p1, p2): boolean {
~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'.
!!! error TS2322: Signature '(p1: any, p2: any): boolean' must have a type predicate.
return true;
};
@@ -158,7 +158,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
var assign2: (p1, p2) => p1 is A;
assign2 = function(p1, p2): p2 is A {
~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
!!! error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
!!! error TS2322: Type predicate 'p2 is A' is not assignable to 'p1 is A'.
!!! error TS2322: Parameter 'p2' is not in the same position as parameter 'p1'.
return true;
@@ -168,7 +168,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
var assign3: (p1, p2) => p1 is A;
assign3 = function(p1, p2, p3): p1 is A {
~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any, p3: any) => boolean' is not assignable to type '(p1: any, p2: any) => boolean'.
!!! error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
return true;
};
@@ -23,13 +23,13 @@ class C extends A {
}
declare function isB(p1): p1 is B;
>isB : (p1: any) => boolean
>isB : (p1: any) => p1 is B
>p1 : any
>p1 : any
>B : B
declare function isC(p1): p1 is C;
>isC : (p1: any) => boolean
>isC : (p1: any) => p1 is C
>p1 : any
>p1 : any
>C : C
@@ -48,7 +48,7 @@ declare function funA<T>(p1: (p1) => T): T;
>T : T
declare function funB<T>(p1: (p1) => T, p2: any): p2 is T;
>funB : <T>(p1: (p1: any) => T, p2: any) => boolean
>funB : <T>(p1: (p1: any) => T, p2: any) => p2 is T
>T : T
>p1 : (p1: any) => T
>p1 : any
@@ -58,18 +58,18 @@ declare function funB<T>(p1: (p1) => T, p2: any): p2 is T;
>T : T
declare function funC<T>(p1: (p1) => p1 is T): T;
>funC : <T>(p1: (p1: any) => boolean) => T
>funC : <T>(p1: (p1: any) => p1 is T) => T
>T : T
>p1 : (p1: any) => boolean
>p1 : (p1: any) => p1 is T
>p1 : any
>p1 : any
>T : T
>T : T
declare function funD<T>(p1: (p1) => p1 is T, p2: any): p2 is T;
>funD : <T>(p1: (p1: any) => boolean, p2: any) => boolean
>funD : <T>(p1: (p1: any) => p1 is T, p2: any) => p2 is T
>T : T
>p1 : (p1: any) => boolean
>p1 : (p1: any) => p1 is T
>p1 : any
>p1 : any
>T : T
@@ -78,10 +78,10 @@ declare function funD<T>(p1: (p1) => p1 is T, p2: any): p2 is T;
>T : T
declare function funE<T, U>(p1: (p1) => p1 is T, p2: U): T;
>funE : <T, U>(p1: (p1: any) => boolean, p2: U) => T
>funE : <T, U>(p1: (p1: any) => p1 is T, p2: U) => T
>T : T
>U : U
>p1 : (p1: any) => boolean
>p1 : (p1: any) => p1 is T
>p1 : any
>p1 : any
>T : T
@@ -97,11 +97,11 @@ let test1: boolean = funA(isB);
>test1 : boolean
>funA(isB) : boolean
>funA : <T>(p1: (p1: any) => T) => T
>isB : (p1: any) => boolean
>isB : (p1: any) => p1 is B
if (funB(retC, a)) {
>funB(retC, a) : boolean
>funB : <T>(p1: (p1: any) => T, p2: any) => boolean
>funB : <T>(p1: (p1: any) => T, p2: any) => p2 is T
>retC : (x: any) => C
>a : A
@@ -114,13 +114,13 @@ let test2: B = funC(isB);
>test2 : B
>B : B
>funC(isB) : B
>funC : <T>(p1: (p1: any) => boolean) => T
>isB : (p1: any) => boolean
>funC : <T>(p1: (p1: any) => p1 is T) => T
>isB : (p1: any) => p1 is B
if (funD(isC, a)) {
>funD(isC, a) : boolean
>funD : <T>(p1: (p1: any) => boolean, p2: any) => boolean
>isC : (p1: any) => boolean
>funD : <T>(p1: (p1: any) => p1 is T, p2: any) => p2 is T
>isC : (p1: any) => p1 is C
>a : A
a.propC;
@@ -132,7 +132,7 @@ let test3: B = funE(isB, 1);
>test3 : B
>B : B
>funE(isB, 1) : B
>funE : <T, U>(p1: (p1: any) => boolean, p2: U) => T
>isB : (p1: any) => boolean
>funE : <T, U>(p1: (p1: any) => p1 is T, p2: U) => T
>isB : (p1: any) => p1 is B
>1 : number
@@ -29,7 +29,7 @@ var strOrNum: string | number;
>strOrNum : string | number
function isC1(x: any): x is C1 {
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>x : any
>x : any
>C1 : C1
@@ -39,7 +39,7 @@ function isC1(x: any): x is C1 {
}
function isC2(x: any): x is C2 {
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>x : any
>x : any
>C2 : C2
@@ -49,7 +49,7 @@ function isC2(x: any): x is C2 {
}
function isD1(x: any): x is D1 {
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>x : any
>x : any
>D1 : D1
@@ -68,7 +68,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1
>str : string
>isC1(c1Orc2) && c1Orc2.p1 : string
>isC1(c1Orc2) : boolean
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>c1Orc2 : C1 | C2
>c1Orc2.p1 : string
>c1Orc2 : C1
@@ -79,7 +79,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2
>num : number
>isC2(c1Orc2) && c1Orc2.p2 : number
>isC2(c1Orc2) : boolean
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>c1Orc2 : C1 | C2
>c1Orc2.p2 : number
>c1Orc2 : C2
@@ -90,7 +90,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1
>str : string
>isD1(c1Orc2) && c1Orc2.p1 : string
>isD1(c1Orc2) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c1Orc2 : C1 | C2
>c1Orc2.p1 : string
>c1Orc2 : D1
@@ -101,7 +101,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1
>num : number
>isD1(c1Orc2) && c1Orc2.p3 : number
>isD1(c1Orc2) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c1Orc2 : C1 | C2
>c1Orc2.p3 : number
>c1Orc2 : D1
@@ -117,7 +117,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2
>num : number
>isC2(c2Ord1) && c2Ord1.p2 : number
>isC2(c2Ord1) : boolean
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>c2Ord1 : C2 | D1
>c2Ord1.p2 : number
>c2Ord1 : C2
@@ -128,7 +128,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1
>num : number
>isD1(c2Ord1) && c2Ord1.p3 : number
>isD1(c2Ord1) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c2Ord1 : C2 | D1
>c2Ord1.p3 : number
>c2Ord1 : D1
@@ -139,7 +139,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1
>str : string
>isD1(c2Ord1) && c2Ord1.p1 : string
>isD1(c2Ord1) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c2Ord1 : C2 | D1
>c2Ord1.p1 : string
>c2Ord1 : D1
@@ -151,7 +151,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
>D1 : D1
>isC1(c2Ord1) && c2Ord1 : D1
>isC1(c2Ord1) : boolean
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>c2Ord1 : C2 | D1
>c2Ord1 : D1
@@ -48,7 +48,7 @@ var strOrNum: string | number;
function isC1(x: any): x is C1 {
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>x : any
>x : any
>C1 : C1
@@ -58,7 +58,7 @@ function isC1(x: any): x is C1 {
}
function isC2(x: any): x is C2 {
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>x : any
>x : any
>C2 : C2
@@ -68,7 +68,7 @@ function isC2(x: any): x is C2 {
}
function isD1(x: any): x is D1 {
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>x : any
>x : any
>D1 : D1
@@ -99,7 +99,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1
>str : string
>isC1(c1Orc2) && c1Orc2.p1 : string
>isC1(c1Orc2) : boolean
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>c1Orc2 : C1 | C2
>c1Orc2.p1 : string
>c1Orc2 : C1
@@ -110,7 +110,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2
>num : number
>isC2(c1Orc2) && c1Orc2.p2 : number
>isC2(c1Orc2) : boolean
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>c1Orc2 : C1 | C2
>c1Orc2.p2 : number
>c1Orc2 : C2
@@ -121,7 +121,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1
>str : string
>isD1(c1Orc2) && c1Orc2.p1 : string
>isD1(c1Orc2) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c1Orc2 : C1 | C2
>c1Orc2.p1 : string
>c1Orc2 : D1
@@ -132,7 +132,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1
>num : number
>isD1(c1Orc2) && c1Orc2.p3 : number
>isD1(c1Orc2) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c1Orc2 : C1 | C2
>c1Orc2.p3 : number
>c1Orc2 : D1
@@ -148,7 +148,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2
>num : number
>isC2(c2Ord1) && c2Ord1.p2 : number
>isC2(c2Ord1) : boolean
>isC2 : (x: any) => boolean
>isC2 : (x: any) => x is C2
>c2Ord1 : C2 | D1
>c2Ord1.p2 : number
>c2Ord1 : C2
@@ -159,7 +159,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1
>num : number
>isD1(c2Ord1) && c2Ord1.p3 : number
>isD1(c2Ord1) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c2Ord1 : C2 | D1
>c2Ord1.p3 : number
>c2Ord1 : D1
@@ -170,7 +170,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1
>str : string
>isD1(c2Ord1) && c2Ord1.p1 : string
>isD1(c2Ord1) : boolean
>isD1 : (x: any) => boolean
>isD1 : (x: any) => x is D1
>c2Ord1 : C2 | D1
>c2Ord1.p1 : string
>c2Ord1 : D1
@@ -182,7 +182,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
>D1 : D1
>isC1(c2Ord1) && c2Ord1 : D1
>isC1(c2Ord1) : boolean
>isC1 : (x: any) => boolean
>isC1 : (x: any) => x is C1
>c2Ord1 : C2 | D1
>c2Ord1 : D1
+13
View File
@@ -28,6 +28,19 @@ export function fooWithSingleOverload(a: any) {
return a;
}
export function fooWithTypePredicate(a: any): a is number {
return true;
}
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
return true;
}
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
return true;
}
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
return true;
}
/** This comment should appear for nonExportedFoo*/
function nonExportedFoo() {
}
@@ -0,0 +1,9 @@
// @declaration: true
function f() {
class C {
public baz = 1;
static foo() { }
public bar() { }
}
}
@@ -0,0 +1,10 @@
// @declaration: true
// @declaration: true
function g() {
var x = class C {
public prop1 = 1;
private foo() { }
static prop2 = 43;
}
}
@@ -0,0 +1,5 @@
function foo<T>(x = class { static prop: T }): T {
return undefined;
}
foo(class { static prop = "hello" }).length;
@@ -0,0 +1,6 @@
function foo<T>(x = class { prop: T }): T {
return undefined;
}
// Should not infer string because it is a static property
foo(class { static prop = "hello" }).length;
@@ -0,0 +1,5 @@
function foo<T>(x = class { prop: T }): T {
return undefined;
}
foo(class { prop = "hello" }).length;
@@ -0,0 +1,27 @@
//@jsx: preserve
//@module: amd
//@filename: react.d.ts
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty {
props;
}
}
interface Props {
foo: string;
}
//@filename: file.tsx
export class MyComponent {
render() {
}
props: { foo: string; }
}
<MyComponent foo="bar" />; // ok
<MyComponent foo={0} />; // should be an error
@@ -0,0 +1,20 @@
/// <reference path="fourslash.ts" />
//// function f1(a: any): a is number {}
//// function f2<T>(a: any): a is T {}
//// function f3(a: any, ...b): a is number {}
//// f1(/*1*/)
//// f2(/*2*/)
//// f3(/*3*/)
goTo.marker("1");
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("f1(a: any): a is number");
goTo.marker("2");
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("f2<T>(a: any): a is T");
goTo.marker("3");
verify.signatureHelpCountIs(1);
verify.currentSignatureHelpIs("f3(a: any, ...b: any[]): a is number");