mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
merge with master
This commit is contained in:
commit
9a9b51f8f1
12
Jakefile.js
12
Jakefile.js
@ -113,7 +113,8 @@ var scriptSources = [
|
||||
"tslint/nextLineRule.ts",
|
||||
"tslint/noNullRule.ts",
|
||||
"tslint/preferConstRule.ts",
|
||||
"tslint/typeOperatorSpacingRule.ts"
|
||||
"tslint/typeOperatorSpacingRule.ts",
|
||||
"tslint/noInOperatorRule.ts"
|
||||
].map(function (f) {
|
||||
return path.join(scriptsDirectory, f);
|
||||
});
|
||||
@ -875,7 +876,8 @@ var tslintRules = ([
|
||||
"noNullRule",
|
||||
"preferConstRule",
|
||||
"booleanTriviaRule",
|
||||
"typeOperatorSpacingRule"
|
||||
"typeOperatorSpacingRule",
|
||||
"noInOperatorRule"
|
||||
]);
|
||||
var tslintRulesFiles = tslintRules.map(function(p) {
|
||||
return path.join(tslintRuleDir, p + ".ts");
|
||||
@ -926,13 +928,17 @@ var lintTargets = compilerSources
|
||||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", ["build-rules"], function() {
|
||||
var lintOptions = getLinterOptions();
|
||||
var failed = 0;
|
||||
for (var i in lintTargets) {
|
||||
var result = lintFile(lintOptions, lintTargets[i]);
|
||||
if (result.failureCount > 0) {
|
||||
console.log(result.output);
|
||||
fail('Linter errors.', result.failureCount);
|
||||
failed += result.failureCount;
|
||||
}
|
||||
}
|
||||
if (failed > 0) {
|
||||
fail('Linter errors.', failed);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
20
scripts/tslint/noInOperatorRule.ts
Normal file
20
scripts/tslint/noInOperatorRule.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
public static FAILURE_STRING = "Don't use the 'in' keyword - use 'hasProperty' to check for key presence instead";
|
||||
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new InWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
}
|
||||
|
||||
class InWalker extends Lint.RuleWalker {
|
||||
visitNode(node: ts.Node) {
|
||||
super.visitNode(node);
|
||||
if (node.kind === ts.SyntaxKind.InKeyword && node.parent && node.parent.kind === ts.SyntaxKind.BinaryExpression) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,9 +141,6 @@ namespace ts {
|
||||
let globalRegExpType: ObjectType;
|
||||
let globalTemplateStringsArrayType: ObjectType;
|
||||
let globalESSymbolType: ObjectType;
|
||||
let jsxElementType: ObjectType;
|
||||
/** Lazily loaded, use getJsxIntrinsicElementType() */
|
||||
let jsxIntrinsicElementsType: ObjectType;
|
||||
let globalIterableType: GenericType;
|
||||
let globalIteratorType: GenericType;
|
||||
let globalIterableIteratorType: GenericType;
|
||||
@ -208,12 +205,17 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
|
||||
let jsxElementType: ObjectType;
|
||||
/** Things we lazy load from the JSX namespace */
|
||||
const jsxTypes: Map<ObjectType> = {};
|
||||
const JsxNames = {
|
||||
JSX: "JSX",
|
||||
IntrinsicElements: "IntrinsicElements",
|
||||
ElementClass: "ElementClass",
|
||||
ElementAttributesPropertyNameContainer: "ElementAttributesProperty",
|
||||
Element: "Element"
|
||||
Element: "Element",
|
||||
IntrinsicAttributes: "IntrinsicAttributes",
|
||||
IntrinsicClassAttributes: "IntrinsicClassAttributes"
|
||||
};
|
||||
|
||||
const subtypeRelation: Map<RelationComparisonResult> = {};
|
||||
@ -7868,12 +7870,11 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
/// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present.
|
||||
function getJsxIntrinsicElementsType() {
|
||||
if (!jsxIntrinsicElementsType) {
|
||||
jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType;
|
||||
function getJsxType(name: string) {
|
||||
if (jsxTypes[name] === undefined) {
|
||||
return jsxTypes[name] = getExportedTypeFromNamespace(JsxNames.JSX, name) || unknownType;
|
||||
}
|
||||
return jsxIntrinsicElementsType;
|
||||
return jsxTypes[name];
|
||||
}
|
||||
|
||||
/// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if
|
||||
@ -7896,7 +7897,7 @@ namespace ts {
|
||||
return links.resolvedSymbol;
|
||||
|
||||
function lookupIntrinsicTag(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
|
||||
const intrinsicElementsType = getJsxIntrinsicElementsType();
|
||||
const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements);
|
||||
if (intrinsicElementsType !== unknownType) {
|
||||
// Property case
|
||||
const intrinsicProp = getPropertyOfType(intrinsicElementsType, (<Identifier>node.tagName).text);
|
||||
@ -7928,7 +7929,7 @@ namespace ts {
|
||||
|
||||
// Look up the value in the current scope
|
||||
if (valueSymbol && valueSymbol !== unknownSymbol) {
|
||||
links.jsxFlags |= JsxFlags.ClassElement;
|
||||
links.jsxFlags |= JsxFlags.ValueElement;
|
||||
if (valueSymbol.flags & SymbolFlags.Alias) {
|
||||
markAliasSymbolAsReferenced(valueSymbol);
|
||||
}
|
||||
@ -7957,7 +7958,7 @@ namespace ts {
|
||||
function getJsxElementInstanceType(node: JsxOpeningLikeElement) {
|
||||
// There is no such thing as an instance type for a non-class element. This
|
||||
// line shouldn't be hit.
|
||||
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), "Should not call getJsxElementInstanceType on non-class Element");
|
||||
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ValueElement), "Should not call getJsxElementInstanceType on non-class Element");
|
||||
|
||||
const classSymbol = getJsxElementTagSymbol(node);
|
||||
if (classSymbol === unknownSymbol) {
|
||||
@ -7984,15 +7985,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const returnType = getUnionType(signatures.map(getReturnTypeOfSignature));
|
||||
|
||||
// Issue an error if this return type isn't assignable to JSX.ElementClass
|
||||
const elemClassType = getJsxGlobalElementClassType();
|
||||
if (elemClassType) {
|
||||
checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
|
||||
}
|
||||
|
||||
return returnType;
|
||||
return getUnionType(signatures.map(getReturnTypeOfSignature));
|
||||
}
|
||||
|
||||
/// e.g. "props" for React.d.ts,
|
||||
@ -8041,9 +8034,31 @@ namespace ts {
|
||||
if (!links.resolvedJsxType) {
|
||||
const sym = getJsxElementTagSymbol(node);
|
||||
|
||||
if (links.jsxFlags & JsxFlags.ClassElement) {
|
||||
if (links.jsxFlags & JsxFlags.ValueElement) {
|
||||
// Get the element instance type (the result of newing or invoking this tag)
|
||||
const elemInstanceType = getJsxElementInstanceType(node);
|
||||
|
||||
// Is this is a stateless function component? See if its single signature is
|
||||
// assignable to the JSX Element Type
|
||||
const callSignature = getSingleCallSignature(getTypeOfSymbol(sym));
|
||||
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
|
||||
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
|
||||
if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType) && (paramType.flags & TypeFlags.ObjectType)) {
|
||||
// Intersect in JSX.IntrinsicAttributes if it exists
|
||||
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
|
||||
if (intrinsicAttributes !== unknownType) {
|
||||
paramType = intersectTypes(intrinsicAttributes, paramType);
|
||||
}
|
||||
return paramType;
|
||||
}
|
||||
|
||||
// Issue an error if this return type isn't assignable to JSX.ElementClass
|
||||
const elemClassType = getJsxGlobalElementClassType();
|
||||
if (elemClassType) {
|
||||
checkTypeRelatedTo(elemInstanceType, elemClassType, assignableRelation, node, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
|
||||
}
|
||||
|
||||
|
||||
if (isTypeAny(elemInstanceType)) {
|
||||
return links.resolvedJsxType = elemInstanceType;
|
||||
}
|
||||
@ -8065,14 +8080,36 @@ namespace ts {
|
||||
return links.resolvedJsxType = emptyObjectType;
|
||||
}
|
||||
else if (isTypeAny(attributesType) || (attributesType === unknownType)) {
|
||||
// Props is of type 'any' or unknown
|
||||
return links.resolvedJsxType = attributesType;
|
||||
}
|
||||
else if (!(attributesType.flags & TypeFlags.ObjectType)) {
|
||||
// Props is not an object type
|
||||
error(node.tagName, Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType));
|
||||
return links.resolvedJsxType = anyType;
|
||||
}
|
||||
else {
|
||||
return links.resolvedJsxType = attributesType;
|
||||
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
||||
let apparentAttributesType = attributesType;
|
||||
const intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes);
|
||||
if (intrinsicClassAttribs !== unknownType) {
|
||||
const typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
||||
if (typeParams) {
|
||||
if (typeParams.length === 1) {
|
||||
apparentAttributesType = intersectTypes(createTypeReference(<GenericType>intrinsicClassAttribs, [elemInstanceType]), apparentAttributesType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
apparentAttributesType = intersectTypes(attributesType, intrinsicClassAttribs);
|
||||
}
|
||||
}
|
||||
|
||||
const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes);
|
||||
if (intrinsicAttribs !== unknownType) {
|
||||
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
||||
}
|
||||
|
||||
return links.resolvedJsxType = apparentAttributesType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8111,7 +8148,7 @@ namespace ts {
|
||||
|
||||
/// Returns all the properties of the Jsx.IntrinsicElements interface
|
||||
function getJsxIntrinsicTagNames(): Symbol[] {
|
||||
const intrinsics = getJsxIntrinsicElementsType();
|
||||
const intrinsics = getJsxType(JsxNames.IntrinsicElements);
|
||||
return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray;
|
||||
}
|
||||
|
||||
@ -9858,7 +9895,7 @@ namespace ts {
|
||||
return aggregatedTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
*TypeScript Specification 1.0 (6.3) - July 2014
|
||||
* An explicitly typed function whose return type isn't the Void or the Any type
|
||||
* must have at least one return statement somewhere in its body.
|
||||
@ -9884,15 +9921,15 @@ namespace ts {
|
||||
const hasExplicitReturn = func.flags & NodeFlags.HasExplicitReturn;
|
||||
|
||||
if (returnType && !hasExplicitReturn) {
|
||||
// minimal check: function has syntactic return type annotation and no explicit return statements in the body
|
||||
// minimal check: function has syntactic return type annotation and no explicit return statements in the body
|
||||
// this function does not conform to the specification.
|
||||
// NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
|
||||
// NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
|
||||
error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
||||
}
|
||||
else if (compilerOptions.noImplicitReturns) {
|
||||
if (!returnType) {
|
||||
// If return type annotation is omitted check if function has any explicit return statements.
|
||||
// If it does not have any - its inferred return type is void - don't do any checks.
|
||||
// If it does not have any - its inferred return type is void - don't do any checks.
|
||||
// Otherwise get inferred return type from function body and report error only if it is not void / anytype
|
||||
const inferredReturnType = hasExplicitReturn
|
||||
? getReturnTypeOfSignature(getSignatureFromDeclaration(func))
|
||||
@ -11922,6 +11959,9 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// If the Promise constructor, resolved locally, is an alias symbol we should mark it as referenced.
|
||||
checkReturnTypeAnnotationAsExpression(node);
|
||||
|
||||
// Validate the promise constructor type.
|
||||
const promiseConstructorType = getTypeOfSymbol(promiseConstructor);
|
||||
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) {
|
||||
@ -11930,11 +11970,11 @@ namespace ts {
|
||||
|
||||
// Verify there is no local declaration that could collide with the promise constructor.
|
||||
const promiseName = getEntityNameFromTypeNode(node.type);
|
||||
const root = getFirstIdentifier(promiseName);
|
||||
const rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value);
|
||||
const promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName);
|
||||
const rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, SymbolFlags.Value);
|
||||
if (rootSymbol) {
|
||||
error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions,
|
||||
root.text,
|
||||
promiseNameOrNamespaceRoot.text,
|
||||
getFullyQualifiedName(promiseConstructor));
|
||||
return unknownType;
|
||||
}
|
||||
@ -12018,24 +12058,12 @@ namespace ts {
|
||||
* Checks the type annotation of an accessor declaration or property declaration as
|
||||
* an expression if it is a type reference to a type with a value declaration.
|
||||
*/
|
||||
function checkTypeAnnotationAsExpression(node: AccessorDeclaration | PropertyDeclaration | ParameterDeclaration | MethodDeclaration) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
checkTypeNodeAsExpression((<PropertyDeclaration>node).type);
|
||||
break;
|
||||
case SyntaxKind.Parameter:
|
||||
checkTypeNodeAsExpression((<ParameterDeclaration>node).type);
|
||||
break;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
checkTypeNodeAsExpression((<MethodDeclaration>node).type);
|
||||
break;
|
||||
case SyntaxKind.GetAccessor:
|
||||
checkTypeNodeAsExpression((<AccessorDeclaration>node).type);
|
||||
break;
|
||||
case SyntaxKind.SetAccessor:
|
||||
checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node));
|
||||
break;
|
||||
}
|
||||
function checkTypeAnnotationAsExpression(node: VariableLikeDeclaration) {
|
||||
checkTypeNodeAsExpression((<PropertyDeclaration>node).type);
|
||||
}
|
||||
|
||||
function checkReturnTypeAnnotationAsExpression(node: FunctionLikeDeclaration) {
|
||||
checkTypeNodeAsExpression(node.type);
|
||||
}
|
||||
|
||||
/** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */
|
||||
@ -12073,11 +12101,12 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
checkParameterTypeAnnotationsAsExpressions(<FunctionLikeDeclaration>node);
|
||||
// fall-through
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
checkParameterTypeAnnotationsAsExpressions(<FunctionLikeDeclaration>node);
|
||||
checkReturnTypeAnnotationAsExpression(<FunctionLikeDeclaration>node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
checkTypeAnnotationAsExpression(<PropertyDeclaration | ParameterDeclaration>node);
|
||||
@ -16285,11 +16314,17 @@ namespace ts {
|
||||
if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) {
|
||||
return true;
|
||||
}
|
||||
if (node.initializer) {
|
||||
return grammarErrorOnNode(node.initializer, Diagnostics.An_interface_property_cannot_have_an_initializer);
|
||||
}
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) {
|
||||
return true;
|
||||
}
|
||||
if (node.initializer) {
|
||||
return grammarErrorOnNode(node.initializer, Diagnostics.A_type_literal_property_cannot_have_an_initializer);
|
||||
}
|
||||
}
|
||||
|
||||
if (isInAmbientContext(node) && node.initializer) {
|
||||
|
||||
@ -1675,7 +1675,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
export function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection) {
|
||||
const emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit);
|
||||
const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath);
|
||||
const emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit;
|
||||
if (!emitSkipped) {
|
||||
const declarationOutput = emitDeclarationResult.referencePathsOutput
|
||||
+ getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo);
|
||||
|
||||
@ -783,6 +783,14 @@
|
||||
"category": "Error",
|
||||
"code": 1245
|
||||
},
|
||||
"An interface property cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1246
|
||||
},
|
||||
"A type literal property cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1247
|
||||
},
|
||||
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
@ -2567,7 +2575,7 @@
|
||||
"Not all code paths return a value.": {
|
||||
"category": "Error",
|
||||
"code": 7030
|
||||
},
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
@ -2190,7 +2190,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emit(node.right);
|
||||
}
|
||||
|
||||
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
|
||||
function emitEntityNameAsExpression(node: EntityName | Expression, useFallback: boolean) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
if (useFallback) {
|
||||
@ -2205,6 +2205,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
case SyntaxKind.QualifiedName:
|
||||
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback);
|
||||
break;
|
||||
|
||||
default:
|
||||
emitNodeWithoutSourceMap(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2978,7 +2982,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else {
|
||||
// this is top level converted loop so we need to create an alias for 'this' here
|
||||
// NOTE:
|
||||
// NOTE:
|
||||
// if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set.
|
||||
// If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'.
|
||||
write(`var ${convertedLoopState.thisName} = this;`);
|
||||
@ -4273,7 +4277,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
// Emit name if one is present, or emit generated name in down-level case (for export default case)
|
||||
return !!node.name || languageVersion < ScriptTarget.ES6;
|
||||
return !!node.name || modulekind !== ModuleKind.ES6;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4455,18 +4459,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
write(" __awaiter(this");
|
||||
if (hasLexicalArguments) {
|
||||
write(", arguments");
|
||||
write(", arguments, ");
|
||||
}
|
||||
else {
|
||||
write(", void 0");
|
||||
write(", void 0, ");
|
||||
}
|
||||
|
||||
if (promiseConstructor) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(promiseConstructor);
|
||||
emitEntityNameAsExpression(promiseConstructor, /*useFallback*/ false);
|
||||
}
|
||||
else {
|
||||
write(", Promise");
|
||||
write("Promise");
|
||||
}
|
||||
|
||||
// Emit the call to __awaiter.
|
||||
@ -4527,7 +4530,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
const isAsync = isAsyncFunctionLike(node);
|
||||
if (isAsync && languageVersion === ScriptTarget.ES6) {
|
||||
if (isAsync) {
|
||||
emitAsyncFunctionBodyForES6(node);
|
||||
}
|
||||
else {
|
||||
@ -5108,7 +5111,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// emit name if
|
||||
// - node has a name
|
||||
// - this is default export with static initializers
|
||||
if ((node.name || (node.flags & NodeFlags.Default && staticProperties.length > 0)) && !thisNodeIsDecorated) {
|
||||
if ((node.name || (node.flags & NodeFlags.Default && (staticProperties.length > 0 || modulekind !== ModuleKind.ES6))) && !thisNodeIsDecorated) {
|
||||
write(" ");
|
||||
emitDeclarationName(node);
|
||||
}
|
||||
@ -5729,7 +5732,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
|
||||
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
|
||||
function emitSerializedReturnTypeOfNode(node: Node) {
|
||||
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
|
||||
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
|
||||
return;
|
||||
@ -7823,7 +7826,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath}: { jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string },
|
||||
sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
// Make sure not to write js File and source map file if any of them cannot be written
|
||||
if (!host.isEmitBlocked(jsFilePath)) {
|
||||
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) {
|
||||
emitJavaScript(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -2259,6 +2259,14 @@ namespace ts {
|
||||
property.name = name;
|
||||
property.questionToken = questionToken;
|
||||
property.type = parseTypeAnnotation();
|
||||
|
||||
if (token === SyntaxKind.EqualsToken) {
|
||||
// Although type literal properties cannot not have initializers, we attempt
|
||||
// to parse an initializer so we can report in the checker that an interface
|
||||
// property or type literal property cannot have an initializer.
|
||||
property.initializer = parseNonParameterInitializer();
|
||||
}
|
||||
|
||||
parseTypeMemberSemicolon();
|
||||
return finishNode(property);
|
||||
}
|
||||
|
||||
@ -439,12 +439,16 @@ namespace ts {
|
||||
|
||||
export const enum JsxFlags {
|
||||
None = 0,
|
||||
/** An element from a named property of the JSX.IntrinsicElements interface */
|
||||
IntrinsicNamedElement = 1 << 0,
|
||||
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
|
||||
IntrinsicIndexedElement = 1 << 1,
|
||||
ClassElement = 1 << 2,
|
||||
UnknownElement = 1 << 3,
|
||||
/** An element backed by a class, class-like, or function value */
|
||||
ValueElement = 1 << 2,
|
||||
/** Element resolution failed */
|
||||
UnknownElement = 1 << 4,
|
||||
|
||||
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement
|
||||
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement,
|
||||
}
|
||||
|
||||
|
||||
@ -587,6 +591,7 @@ namespace ts {
|
||||
name: PropertyName; // Declared property name
|
||||
questionToken?: Node; // Present on optional property
|
||||
type?: TypeNode; // Optional type annotation
|
||||
initializer?: Expression; // Optional initializer
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.PropertyDeclaration)
|
||||
|
||||
@ -155,7 +155,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
it("Correct JS output for " + fileName, () => {
|
||||
if (hasNonDtsFiles && this.emit) {
|
||||
if (result.files.length === 0 && result.errors.length === 0) {
|
||||
if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) {
|
||||
throw new Error("Expected at least one js file to be emitted or at least one error to be created.");
|
||||
}
|
||||
|
||||
|
||||
@ -908,6 +908,7 @@ namespace Harness {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
includeBuiltFile?: string;
|
||||
baselineFile?: string;
|
||||
libFiles?: string;
|
||||
}
|
||||
|
||||
// Additional options not already in ts.optionDeclarations
|
||||
@ -917,6 +918,7 @@ namespace Harness {
|
||||
{ name: "baselineFile", type: "string" },
|
||||
{ name: "includeBuiltFile", type: "string" },
|
||||
{ name: "fileName", type: "string" },
|
||||
{ name: "libFiles", type: "string" },
|
||||
{ name: "noErrorTruncation", type: "boolean" }
|
||||
];
|
||||
|
||||
@ -995,13 +997,9 @@ namespace Harness {
|
||||
currentDirectory = currentDirectory || Harness.IO.getCurrentDirectory();
|
||||
|
||||
// Parse settings
|
||||
let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames();
|
||||
if (harnessSettings) {
|
||||
setCompilerOptionsFromHarnessSetting(harnessSettings, options);
|
||||
}
|
||||
if (options.useCaseSensitiveFileNames !== undefined) {
|
||||
useCaseSensitiveFileNames = options.useCaseSensitiveFileNames;
|
||||
}
|
||||
if (options.inferredBaseUrl) {
|
||||
options.inferredBaseUrl = ts.getNormalizedAbsolutePath(options.inferredBaseUrl, currentDirectory);
|
||||
}
|
||||
@ -1009,6 +1007,7 @@ namespace Harness {
|
||||
options.rootDirs = ts.map(options.rootDirs, d => ts.getNormalizedAbsolutePath(d, currentDirectory));
|
||||
}
|
||||
|
||||
const useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames();
|
||||
const programFiles: TestFile[] = inputFiles.slice();
|
||||
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
|
||||
// Treat them as library files, so include them in build, but not in baselines.
|
||||
@ -1023,6 +1022,15 @@ namespace Harness {
|
||||
|
||||
const fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
// Files from tests\lib that are requested by "@libFiles"
|
||||
if (options.libFiles) {
|
||||
for (const fileName of options.libFiles.split(",")) {
|
||||
const libFileName = "tests/lib/" + fileName;
|
||||
programFiles.push({ unitName: libFileName, content: normalizeLineEndings(IO.readFile(libFileName), Harness.IO.newLine()) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const programFileNames = programFiles.map(file => file.unitName);
|
||||
|
||||
const compilerHost = createCompilerHost(
|
||||
|
||||
23
src/lib/dom.generated.d.ts
vendored
23
src/lib/dom.generated.d.ts
vendored
@ -2058,6 +2058,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* Gets or sets the version attribute specified in the declaration of an XML document.
|
||||
*/
|
||||
xmlVersion: string;
|
||||
currentScript: HTMLScriptElement;
|
||||
adoptNode(source: Node): Node;
|
||||
captureEvents(): void;
|
||||
clear(): void;
|
||||
@ -2977,6 +2978,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
webkitRequestFullScreen(): void;
|
||||
webkitRequestFullscreen(): void;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
matches(selector: string): boolean;
|
||||
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
|
||||
@ -3961,7 +3963,6 @@ interface HTMLElement extends Element {
|
||||
title: string;
|
||||
blur(): void;
|
||||
click(): void;
|
||||
contains(child: HTMLElement): boolean;
|
||||
dragDrop(): boolean;
|
||||
focus(): void;
|
||||
insertAdjacentElement(position: string, insertedElement: Element): Element;
|
||||
@ -6135,7 +6136,7 @@ interface HTMLSelectElement extends HTMLElement {
|
||||
* Sets or retrieves the name of the object.
|
||||
*/
|
||||
name: string;
|
||||
options: HTMLSelectElement;
|
||||
options: HTMLCollection;
|
||||
/**
|
||||
* When present, marks an element that can't be submitted without a value.
|
||||
*/
|
||||
@ -6421,19 +6422,19 @@ interface HTMLTableElement extends HTMLElement {
|
||||
/**
|
||||
* Creates an empty caption element in the table.
|
||||
*/
|
||||
createCaption(): HTMLElement;
|
||||
createCaption(): HTMLTableCaptionElement;
|
||||
/**
|
||||
* Creates an empty tBody element in the table.
|
||||
*/
|
||||
createTBody(): HTMLElement;
|
||||
createTBody(): HTMLTableSectionElement;
|
||||
/**
|
||||
* Creates an empty tFoot element in the table.
|
||||
*/
|
||||
createTFoot(): HTMLElement;
|
||||
createTFoot(): HTMLTableSectionElement;
|
||||
/**
|
||||
* Returns the tHead element object if successful, or null otherwise.
|
||||
*/
|
||||
createTHead(): HTMLElement;
|
||||
createTHead(): HTMLTableSectionElement;
|
||||
/**
|
||||
* Deletes the caption element and its contents from the table.
|
||||
*/
|
||||
@ -6455,7 +6456,7 @@ interface HTMLTableElement extends HTMLElement {
|
||||
* Creates a new row (tr) in the table, and adds the row to the rows collection.
|
||||
* @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection.
|
||||
*/
|
||||
insertRow(index?: number): HTMLElement;
|
||||
insertRow(index?: number): HTMLTableRowElement;
|
||||
}
|
||||
|
||||
declare var HTMLTableElement: {
|
||||
@ -6506,7 +6507,7 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment {
|
||||
* Creates a new cell in the table row, and adds the cell to the cells collection.
|
||||
* @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection.
|
||||
*/
|
||||
insertCell(index?: number): HTMLElement;
|
||||
insertCell(index?: number): HTMLTableCellElement;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@ -6533,7 +6534,7 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment {
|
||||
* Creates a new row (tr) in the table, and adds the row to the rows collection.
|
||||
* @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection.
|
||||
*/
|
||||
insertRow(index?: number): HTMLElement;
|
||||
insertRow(index?: number): HTMLTableRowElement;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@ -7071,7 +7072,7 @@ declare var IDBVersionChangeEvent: {
|
||||
}
|
||||
|
||||
interface ImageData {
|
||||
data: number[];
|
||||
data: Uint8ClampedArray;
|
||||
height: number;
|
||||
width: number;
|
||||
}
|
||||
@ -7869,6 +7870,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte
|
||||
getGamepads(): Gamepad[];
|
||||
javaEnabled(): boolean;
|
||||
msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void;
|
||||
vibrate(pattern: number | number[]): boolean;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@ -7909,6 +7911,7 @@ interface Node extends EventTarget {
|
||||
normalize(): void;
|
||||
removeChild(oldChild: Node): Node;
|
||||
replaceChild(newChild: Node, oldChild: Node): Node;
|
||||
contains(node: Node): boolean;
|
||||
ATTRIBUTE_NODE: number;
|
||||
CDATA_SECTION_NODE: number;
|
||||
COMMENT_NODE: number;
|
||||
|
||||
2
src/lib/webworker.generated.d.ts
vendored
2
src/lib/webworker.generated.d.ts
vendored
@ -460,7 +460,7 @@ declare var IDBVersionChangeEvent: {
|
||||
}
|
||||
|
||||
interface ImageData {
|
||||
data: number[];
|
||||
data: Uint8ClampedArray;
|
||||
height: number;
|
||||
width: number;
|
||||
}
|
||||
|
||||
21
tests/baselines/reference/anonymousDefaultExportsAmd.js
Normal file
21
tests/baselines/reference/anonymousDefaultExportsAmd.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/es6/moduleExportsAmd/anonymousDefaultExportsAmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function() {}
|
||||
|
||||
//// [a.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
exports.default = default_1;
|
||||
});
|
||||
//// [b.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
exports.default = default_1;
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
17
tests/baselines/reference/anonymousDefaultExportsCommonjs.js
Normal file
17
tests/baselines/reference/anonymousDefaultExportsCommonjs.js
Normal file
@ -0,0 +1,17 @@
|
||||
//// [tests/cases/conformance/es6/moduleExportsCommonjs/anonymousDefaultExportsCommonjs.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function() {}
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
exports.default = default_1;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
exports.default = default_1;
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
32
tests/baselines/reference/anonymousDefaultExportsSystem.js
Normal file
32
tests/baselines/reference/anonymousDefaultExportsSystem.js
Normal file
@ -0,0 +1,32 @@
|
||||
//// [tests/cases/conformance/es6/moduleExportsSystem/anonymousDefaultExportsSystem.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function() {}
|
||||
|
||||
//// [a.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
var default_1;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
class default_1 {
|
||||
}
|
||||
exports_1("default", default_1);
|
||||
}
|
||||
}
|
||||
});
|
||||
//// [b.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
exports_1("default", default_1);
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
35
tests/baselines/reference/anonymousDefaultExportsUmd.js
Normal file
35
tests/baselines/reference/anonymousDefaultExportsUmd.js
Normal file
@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/es6/moduleExportsUmd/anonymousDefaultExportsUmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function() {}
|
||||
|
||||
//// [a.js]
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
class default_1 {
|
||||
}
|
||||
exports.default = default_1;
|
||||
});
|
||||
//// [b.js]
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
function default_1() { }
|
||||
exports.default = default_1;
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
export default class {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
export default function() {}
|
||||
No type information for this code.
|
||||
@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/async/es6/asyncAliasReturnType_es6.ts(3,16): error TS1055: Type 'PromiseAlias' is not a valid async function return type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/asyncAliasReturnType_es6.ts (1 errors) ====
|
||||
type PromiseAlias<T> = Promise<T>;
|
||||
|
||||
async function f(): PromiseAlias<void> {
|
||||
~
|
||||
!!! error TS1055: Type 'PromiseAlias' is not a valid async function return type.
|
||||
}
|
||||
11
tests/baselines/reference/asyncAliasReturnType_es6.js
Normal file
11
tests/baselines/reference/asyncAliasReturnType_es6.js
Normal file
@ -0,0 +1,11 @@
|
||||
//// [asyncAliasReturnType_es6.ts]
|
||||
type PromiseAlias<T> = Promise<T>;
|
||||
|
||||
async function f(): PromiseAlias<void> {
|
||||
}
|
||||
|
||||
//// [asyncAliasReturnType_es6.js]
|
||||
function f() {
|
||||
return __awaiter(this, void 0, PromiseAlias, function* () {
|
||||
});
|
||||
}
|
||||
37
tests/baselines/reference/asyncImportedPromise_es6.js
Normal file
37
tests/baselines/reference/asyncImportedPromise_es6.js
Normal file
@ -0,0 +1,37 @@
|
||||
//// [tests/cases/conformance/async/es6/asyncImportedPromise_es6.ts] ////
|
||||
|
||||
//// [task.ts]
|
||||
export class Task<T> extends Promise<T> { }
|
||||
|
||||
//// [test.ts]
|
||||
import { Task } from "./task";
|
||||
class Test {
|
||||
async example<T>(): Task<T> { return; }
|
||||
}
|
||||
|
||||
//// [task.js]
|
||||
"use strict";
|
||||
class Task extends Promise {
|
||||
}
|
||||
exports.Task = Task;
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
generator = generator.call(thisArg, _arguments);
|
||||
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
|
||||
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
|
||||
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
|
||||
function step(verb, value) {
|
||||
var result = generator[verb](value);
|
||||
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
|
||||
}
|
||||
step("next", void 0);
|
||||
});
|
||||
};
|
||||
var task_1 = require("./task");
|
||||
class Test {
|
||||
example() {
|
||||
return __awaiter(this, void 0, task_1.Task, function* () { return; });
|
||||
}
|
||||
}
|
||||
20
tests/baselines/reference/asyncImportedPromise_es6.symbols
Normal file
20
tests/baselines/reference/asyncImportedPromise_es6.symbols
Normal file
@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/async/es6/task.ts ===
|
||||
export class Task<T> extends Promise<T> { }
|
||||
>Task : Symbol(Task, Decl(task.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(task.ts, 0, 18))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(task.ts, 0, 18))
|
||||
|
||||
=== tests/cases/conformance/async/es6/test.ts ===
|
||||
import { Task } from "./task";
|
||||
>Task : Symbol(Task, Decl(test.ts, 0, 8))
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(test.ts, 0, 30))
|
||||
|
||||
async example<T>(): Task<T> { return; }
|
||||
>example : Symbol(example, Decl(test.ts, 1, 12))
|
||||
>T : Symbol(T, Decl(test.ts, 2, 18))
|
||||
>Task : Symbol(Task, Decl(test.ts, 0, 8))
|
||||
>T : Symbol(T, Decl(test.ts, 2, 18))
|
||||
}
|
||||
20
tests/baselines/reference/asyncImportedPromise_es6.types
Normal file
20
tests/baselines/reference/asyncImportedPromise_es6.types
Normal file
@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/async/es6/task.ts ===
|
||||
export class Task<T> extends Promise<T> { }
|
||||
>Task : Task<T>
|
||||
>T : T
|
||||
>Promise : Promise<T>
|
||||
>T : T
|
||||
|
||||
=== tests/cases/conformance/async/es6/test.ts ===
|
||||
import { Task } from "./task";
|
||||
>Task : typeof Task
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
|
||||
async example<T>(): Task<T> { return; }
|
||||
>example : <T>() => Task<T>
|
||||
>T : T
|
||||
>Task : Task<T>
|
||||
>T : T
|
||||
}
|
||||
20
tests/baselines/reference/asyncQualifiedReturnType_es6.js
Normal file
20
tests/baselines/reference/asyncQualifiedReturnType_es6.js
Normal file
@ -0,0 +1,20 @@
|
||||
//// [asyncQualifiedReturnType_es6.ts]
|
||||
namespace X {
|
||||
export class MyPromise<T> extends Promise<T> {
|
||||
}
|
||||
}
|
||||
|
||||
async function f(): X.MyPromise<void> {
|
||||
}
|
||||
|
||||
//// [asyncQualifiedReturnType_es6.js]
|
||||
var X;
|
||||
(function (X) {
|
||||
class MyPromise extends Promise {
|
||||
}
|
||||
X.MyPromise = MyPromise;
|
||||
})(X || (X = {}));
|
||||
function f() {
|
||||
return __awaiter(this, void 0, X.MyPromise, function* () {
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts ===
|
||||
namespace X {
|
||||
>X : Symbol(X, Decl(asyncQualifiedReturnType_es6.ts, 0, 0))
|
||||
|
||||
export class MyPromise<T> extends Promise<T> {
|
||||
>MyPromise : Symbol(MyPromise, Decl(asyncQualifiedReturnType_es6.ts, 0, 13))
|
||||
>T : Symbol(T, Decl(asyncQualifiedReturnType_es6.ts, 1, 27))
|
||||
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(asyncQualifiedReturnType_es6.ts, 1, 27))
|
||||
}
|
||||
}
|
||||
|
||||
async function f(): X.MyPromise<void> {
|
||||
>f : Symbol(f, Decl(asyncQualifiedReturnType_es6.ts, 3, 1))
|
||||
>X : Symbol(X, Decl(asyncQualifiedReturnType_es6.ts, 0, 0))
|
||||
>MyPromise : Symbol(X.MyPromise, Decl(asyncQualifiedReturnType_es6.ts, 0, 13))
|
||||
}
|
||||
17
tests/baselines/reference/asyncQualifiedReturnType_es6.types
Normal file
17
tests/baselines/reference/asyncQualifiedReturnType_es6.types
Normal file
@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts ===
|
||||
namespace X {
|
||||
>X : typeof X
|
||||
|
||||
export class MyPromise<T> extends Promise<T> {
|
||||
>MyPromise : MyPromise<T>
|
||||
>T : T
|
||||
>Promise : Promise<T>
|
||||
>T : T
|
||||
}
|
||||
}
|
||||
|
||||
async function f(): X.MyPromise<void> {
|
||||
>f : () => X.MyPromise<void>
|
||||
>X : any
|
||||
>MyPromise : X.MyPromise<T>
|
||||
}
|
||||
@ -1,12 +1,19 @@
|
||||
//// [decoratedDefaultExportsGetExportedAmd.ts]
|
||||
|
||||
//// [tests/cases/conformance/es6/moduleExportsAmd/decoratedDefaultExportsGetExportedAmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
//// [decoratedDefaultExportsGetExportedAmd.js]
|
||||
|
||||
//// [a.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
@ -23,3 +30,20 @@ define(["require", "exports"], function (require, exports) {
|
||||
], Foo);
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var decorator;
|
||||
let default_1 = class {
|
||||
};
|
||||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/decoratedDefaultExportsGetExportedAmd.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedAmd.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedAmd.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(decoratedDefaultExportsGetExportedAmd.ts, 1, 30))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 30))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/decoratedDefaultExportsGetExportedAmd.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
@ -10,3 +9,13 @@ var decorator: ClassDecorator;
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
@decorator
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
//// [decoratedDefaultExportsGetExportedCommonjs.ts]
|
||||
|
||||
//// [tests/cases/conformance/es6/moduleExportsCommonjs/decoratedDefaultExportsGetExportedCommonjs.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
//// [decoratedDefaultExportsGetExportedCommonjs.js]
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
@ -21,3 +28,18 @@ Foo = __decorate([
|
||||
decorator
|
||||
], Foo);
|
||||
exports.default = Foo;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var decorator;
|
||||
let default_1 = class {
|
||||
};
|
||||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
exports.default = default_1;
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/decoratedDefaultExportsGetExportedCommonjs.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedCommonjs.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedCommonjs.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(decoratedDefaultExportsGetExportedCommonjs.ts, 1, 30))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 30))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/decoratedDefaultExportsGetExportedCommonjs.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
@ -10,3 +9,13 @@ var decorator: ClassDecorator;
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
@decorator
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
//// [decoratedDefaultExportsGetExportedSystem.ts]
|
||||
|
||||
//// [tests/cases/conformance/es6/moduleExportsSystem/decoratedDefaultExportsGetExportedSystem.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
//// [decoratedDefaultExportsGetExportedSystem.js]
|
||||
//// [a.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
@ -28,3 +34,25 @@ System.register([], function(exports_1) {
|
||||
}
|
||||
}
|
||||
});
|
||||
//// [b.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var decorator, default_1;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
let default_1 = class {
|
||||
};
|
||||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
exports_1("default", default_1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/decoratedDefaultExportsGetExportedSystem.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedSystem.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedSystem.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(decoratedDefaultExportsGetExportedSystem.ts, 1, 30))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 30))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
|
||||
export default class {}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/decoratedDefaultExportsGetExportedSystem.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
@ -10,3 +9,12 @@ var decorator: ClassDecorator;
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
@decorator
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
export default class {}
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
//// [decoratedDefaultExportsGetExportedUmd.ts]
|
||||
|
||||
//// [tests/cases/conformance/es6/moduleExportsUmd/decoratedDefaultExportsGetExportedUmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
//// [decoratedDefaultExportsGetExportedUmd.js]
|
||||
|
||||
//// [a.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
@ -30,3 +37,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
], Foo);
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
var decorator;
|
||||
let default_1 = class {
|
||||
};
|
||||
default_1 = __decorate([
|
||||
decorator
|
||||
], default_1);
|
||||
exports.default = default_1;
|
||||
});
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/decoratedDefaultExportsGetExportedUmd.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedUmd.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratedDefaultExportsGetExportedUmd.ts, 1, 3))
|
||||
>decorator : Symbol(decorator, Decl(a.ts, 0, 3))
|
||||
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(decoratedDefaultExportsGetExportedUmd.ts, 1, 30))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 30))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(b.ts, 0, 3))
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/decoratedDefaultExportsGetExportedUmd.ts ===
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
@ -10,3 +9,13 @@ var decorator: ClassDecorator;
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
var decorator: ClassDecorator;
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
@decorator
|
||||
>decorator : <TFunction extends Function>(target: TFunction) => TFunction | void
|
||||
|
||||
export default class {}
|
||||
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
//// [defaultExportsGetExportedAmd.ts]
|
||||
//// [tests/cases/conformance/es6/moduleExportsAmd/defaultExportsGetExportedAmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function foo() {}
|
||||
|
||||
//// [defaultExportsGetExportedAmd.js]
|
||||
|
||||
//// [a.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
class Foo {
|
||||
}
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
exports.default = foo;
|
||||
});
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/defaultExportsGetExportedAmd.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultExportsGetExportedAmd.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/defaultExportsGetExportedAmd.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsAmd/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : () => void
|
||||
|
||||
|
||||
@ -1,9 +1,18 @@
|
||||
//// [defaultExportsGetExportedCommonjs.ts]
|
||||
//// [tests/cases/conformance/es6/moduleExportsCommonjs/defaultExportsGetExportedCommonjs.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function foo() {}
|
||||
|
||||
//// [defaultExportsGetExportedCommonjs.js]
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
class Foo {
|
||||
}
|
||||
exports.default = Foo;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
function foo() { }
|
||||
exports.default = foo;
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/defaultExportsGetExportedCommonjs.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultExportsGetExportedCommonjs.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/defaultExportsGetExportedCommonjs.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsCommonjs/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : () => void
|
||||
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
//// [defaultExportsGetExportedSystem.ts]
|
||||
//// [tests/cases/conformance/es6/moduleExportsSystem/defaultExportsGetExportedSystem.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function foo() {}
|
||||
|
||||
//// [defaultExportsGetExportedSystem.js]
|
||||
|
||||
//// [a.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
var Foo;
|
||||
@ -15,3 +20,14 @@ System.register([], function(exports_1) {
|
||||
}
|
||||
}
|
||||
});
|
||||
//// [b.js]
|
||||
System.register([], function(exports_1) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
exports_1("default", foo);
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/defaultExportsGetExportedSystem.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultExportsGetExportedSystem.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/defaultExportsGetExportedSystem.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsSystem/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : () => void
|
||||
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
//// [defaultExportsGetExportedUmd.ts]
|
||||
//// [tests/cases/conformance/es6/moduleExportsUmd/defaultExportsGetExportedUmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
export default function foo() {}
|
||||
|
||||
//// [defaultExportsGetExportedUmd.js]
|
||||
|
||||
//// [a.js]
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
@ -16,3 +21,16 @@ export default class Foo {}
|
||||
}
|
||||
exports.default = Foo;
|
||||
});
|
||||
//// [b.js]
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
function foo() { }
|
||||
exports.default = foo;
|
||||
});
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/defaultExportsGetExportedUmd.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Symbol(Foo, Decl(defaultExportsGetExportedUmd.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 0))
|
||||
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/defaultExportsGetExportedUmd.ts ===
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/a.ts ===
|
||||
export default class Foo {}
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/conformance/es6/moduleExportsUmd/b.ts ===
|
||||
export default function foo() {}
|
||||
>foo : () => void
|
||||
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts(2,19): error TS1246: An interface property cannot have an initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorOnInitializerInInterfaceProperty.ts (1 errors) ====
|
||||
interface Foo {
|
||||
bar: number = 5;
|
||||
~
|
||||
!!! error TS1246: An interface property cannot have an initializer.
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
//// [errorOnInitializerInInterfaceProperty.ts]
|
||||
interface Foo {
|
||||
bar: number = 5;
|
||||
}
|
||||
|
||||
|
||||
//// [errorOnInitializerInInterfaceProperty.js]
|
||||
@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts(2,19): error TS1247: A type literal property cannot have an initializer.
|
||||
tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts(6,19): error TS1247: A type literal property cannot have an initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorOnInitializerInObjectTypeLiteralProperty.ts (2 errors) ====
|
||||
var Foo: {
|
||||
bar: number = 5;
|
||||
~
|
||||
!!! error TS1247: A type literal property cannot have an initializer.
|
||||
};
|
||||
|
||||
let Bar: {
|
||||
bar: number = 5;
|
||||
~
|
||||
!!! error TS1247: A type literal property cannot have an initializer.
|
||||
};
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
//// [errorOnInitializerInObjectTypeLiteralProperty.ts]
|
||||
var Foo: {
|
||||
bar: number = 5;
|
||||
};
|
||||
|
||||
let Bar: {
|
||||
bar: number = 5;
|
||||
};
|
||||
|
||||
|
||||
//// [errorOnInitializerInObjectTypeLiteralProperty.js]
|
||||
var Foo;
|
||||
var Bar;
|
||||
@ -1,25 +0,0 @@
|
||||
//// [a.js]
|
||||
let C = "sss";
|
||||
let C = 0; // Error: Cannot redeclare block-scoped variable 'C'.
|
||||
|
||||
function f() {
|
||||
return;
|
||||
return; // Error: Unreachable code detected.
|
||||
}
|
||||
|
||||
function b() {
|
||||
"use strict";
|
||||
var arguments = 0; // Error: Invalid use of 'arguments' in strict mode.
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
var C = "sss";
|
||||
var C = 0; // Error: Cannot redeclare block-scoped variable 'C'.
|
||||
function f() {
|
||||
return;
|
||||
return; // Error: Unreachable code detected.
|
||||
}
|
||||
function b() {
|
||||
"use strict";
|
||||
var arguments = 0; // Error: Invalid use of 'arguments' in strict mode.
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,9): error TS2324: Property 'name' is missing in type 'IntrinsicAttributes & { name: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(12,16): error TS2339: Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,15): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(21,15): error TS2339: Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
|
||||
|
||||
function Greet(x: {name: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
function Meet({name = 'world'}) {
|
||||
return <div>Hello, {name}</div>;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet name='world' />;
|
||||
// Error
|
||||
let b = <Greet naaame='world' />;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2324: Property 'name' is missing in type 'IntrinsicAttributes & { name: string; }'.
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'.
|
||||
|
||||
// OK
|
||||
let c = <Meet />;
|
||||
// OK
|
||||
let d = <Meet name='me' />;
|
||||
// Error
|
||||
let e = <Meet name={42} />;
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
// Error
|
||||
let f = <Meet naaaaaaame='no' />;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
|
||||
44
tests/baselines/reference/tsxStatelessFunctionComponents1.js
Normal file
44
tests/baselines/reference/tsxStatelessFunctionComponents1.js
Normal file
@ -0,0 +1,44 @@
|
||||
//// [file.tsx]
|
||||
|
||||
function Greet(x: {name: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
function Meet({name = 'world'}) {
|
||||
return <div>Hello, {name}</div>;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet name='world' />;
|
||||
// Error
|
||||
let b = <Greet naaame='world' />;
|
||||
|
||||
// OK
|
||||
let c = <Meet />;
|
||||
// OK
|
||||
let d = <Meet name='me' />;
|
||||
// Error
|
||||
let e = <Meet name={42} />;
|
||||
// Error
|
||||
let f = <Meet naaaaaaame='no' />;
|
||||
|
||||
|
||||
//// [file.jsx]
|
||||
function Greet(x) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
function Meet(_a) {
|
||||
var _b = _a.name, name = _b === void 0 ? 'world' : _b;
|
||||
return <div>Hello, {name}</div>;
|
||||
}
|
||||
// OK
|
||||
var a = <Greet name='world'/>;
|
||||
// Error
|
||||
var b = <Greet naaame='world'/>;
|
||||
// OK
|
||||
var c = <Meet />;
|
||||
// OK
|
||||
var d = <Meet name='me'/>;
|
||||
// Error
|
||||
var e = <Meet name={42}/>;
|
||||
// Error
|
||||
var f = <Meet naaaaaaame='no'/>;
|
||||
@ -0,0 +1,56 @@
|
||||
tests/cases/conformance/jsx/file.tsx(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided.
|
||||
tests/cases/conformance/jsx/file.tsx(20,16): error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(26,42): error TS2339: Property 'subtr' does not exist on type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(28,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
|
||||
tests/cases/conformance/jsx/file.tsx(36,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (5 errors) ====
|
||||
|
||||
import React = require('react');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile modules unless the '--module' flag is provided.
|
||||
|
||||
function Greet(x: {name?: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
|
||||
class BigGreeter extends React.Component<{ name?: string }, {}> {
|
||||
render() {
|
||||
return <div></div>;
|
||||
}
|
||||
greeting: string;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet />;
|
||||
// OK - always valid to specify 'key'
|
||||
let b = <Greet key="k" />;
|
||||
// Error - not allowed to specify 'ref' on SFCs
|
||||
let c = <Greet ref="myRef" />;
|
||||
~~~
|
||||
!!! error TS2339: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
|
||||
|
||||
// OK - ref is valid for classes
|
||||
let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
|
||||
// Error ('subtr' not on string)
|
||||
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'subtr' does not exist on type 'string'.
|
||||
// Error (ref callback is contextually typed)
|
||||
let f = <BigGreeter ref={x => x.notARealProperty} />;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
|
||||
|
||||
// OK - key is always valid
|
||||
let g = <BigGreeter key={100} />;
|
||||
|
||||
// OK - contextually typed intrinsic ref callback parameter
|
||||
let h = <div ref={x => x.innerText} />;
|
||||
// Error - property not on ontextually typed intrinsic ref callback parameter
|
||||
let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
|
||||
|
||||
|
||||
79
tests/baselines/reference/tsxStatelessFunctionComponents2.js
Normal file
79
tests/baselines/reference/tsxStatelessFunctionComponents2.js
Normal file
@ -0,0 +1,79 @@
|
||||
//// [file.tsx]
|
||||
|
||||
import React = require('react');
|
||||
|
||||
function Greet(x: {name?: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
|
||||
class BigGreeter extends React.Component<{ name?: string }, {}> {
|
||||
render() {
|
||||
return <div></div>;
|
||||
}
|
||||
greeting: string;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet />;
|
||||
// OK - always valid to specify 'key'
|
||||
let b = <Greet key="k" />;
|
||||
// Error - not allowed to specify 'ref' on SFCs
|
||||
let c = <Greet ref="myRef" />;
|
||||
|
||||
|
||||
// OK - ref is valid for classes
|
||||
let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
|
||||
// Error ('subtr' not on string)
|
||||
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
|
||||
// Error (ref callback is contextually typed)
|
||||
let f = <BigGreeter ref={x => x.notARealProperty} />;
|
||||
|
||||
// OK - key is always valid
|
||||
let g = <BigGreeter key={100} />;
|
||||
|
||||
// OK - contextually typed intrinsic ref callback parameter
|
||||
let h = <div ref={x => x.innerText} />;
|
||||
// Error - property not on ontextually typed intrinsic ref callback parameter
|
||||
let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
|
||||
|
||||
|
||||
|
||||
//// [file.jsx]
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var React = require('react');
|
||||
function Greet(x) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
var BigGreeter = (function (_super) {
|
||||
__extends(BigGreeter, _super);
|
||||
function BigGreeter() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
BigGreeter.prototype.render = function () {
|
||||
return <div></div>;
|
||||
};
|
||||
return BigGreeter;
|
||||
})(React.Component);
|
||||
// OK
|
||||
var a = <Greet />;
|
||||
// OK - always valid to specify 'key'
|
||||
var b = <Greet key="k"/>;
|
||||
// Error - not allowed to specify 'ref' on SFCs
|
||||
var c = <Greet ref="myRef"/>;
|
||||
// OK - ref is valid for classes
|
||||
var d = <BigGreeter ref={function (x) { return x.greeting.substr(10); }}/>;
|
||||
// Error ('subtr' not on string)
|
||||
var e = <BigGreeter ref={function (x) { return x.greeting.subtr(10); }}/>;
|
||||
// Error (ref callback is contextually typed)
|
||||
var f = <BigGreeter ref={function (x) { return x.notARealProperty; }}/>;
|
||||
// OK - key is always valid
|
||||
var g = <BigGreeter key={100}/>;
|
||||
// OK - contextually typed intrinsic ref callback parameter
|
||||
var h = <div ref={function (x) { return x.innerText; }}/>;
|
||||
// Error - property not on ontextually typed intrinsic ref callback parameter
|
||||
var i = <div ref={function (x) { return x.propertyNotOnHtmlDivElement; }}/>;
|
||||
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
bar: number = 5;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
var Foo: {
|
||||
bar: number = 5;
|
||||
};
|
||||
|
||||
let Bar: {
|
||||
bar: number = 5;
|
||||
};
|
||||
@ -0,0 +1,6 @@
|
||||
// @target: ES6
|
||||
// @noEmitHelpers: true
|
||||
type PromiseAlias<T> = Promise<T>;
|
||||
|
||||
async function f(): PromiseAlias<void> {
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @filename: task.ts
|
||||
export class Task<T> extends Promise<T> { }
|
||||
|
||||
// @filename: test.ts
|
||||
import { Task } from "./task";
|
||||
class Test {
|
||||
async example<T>(): Task<T> { return; }
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// @target: ES6
|
||||
// @noEmitHelpers: true
|
||||
namespace X {
|
||||
export class MyPromise<T> extends Promise<T> {
|
||||
}
|
||||
}
|
||||
|
||||
async function f(): X.MyPromise<void> {
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: amd
|
||||
// @filename: a.ts
|
||||
export default class {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function() {}
|
||||
@ -1,8 +1,14 @@
|
||||
// @target: ES6
|
||||
// @experimentalDecorators: true
|
||||
// @module: amd
|
||||
|
||||
// @filename: a.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: amd
|
||||
// @filename: a.ts
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function foo() {}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: commonjs
|
||||
// @filename: a.ts
|
||||
export default class {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function() {}
|
||||
@ -1,8 +1,14 @@
|
||||
// @target: ES6
|
||||
// @experimentalDecorators: true
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: a.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: commonjs
|
||||
// @filename: a.ts
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function foo() {}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: system
|
||||
// @filename: a.ts
|
||||
export default class {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function() {}
|
||||
@ -1,8 +1,14 @@
|
||||
// @target: ES6
|
||||
// @experimentalDecorators: true
|
||||
// @module: system
|
||||
|
||||
// @filename: a.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
@ -1,3 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: system
|
||||
// @filename: a.ts
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function foo() {}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: umd
|
||||
// @filename: a.ts
|
||||
export default class {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function() {}
|
||||
@ -1,8 +1,14 @@
|
||||
// @target: ES6
|
||||
// @experimentalDecorators: true
|
||||
// @module: umd
|
||||
|
||||
// @filename: a.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
var decorator: ClassDecorator;
|
||||
|
||||
@decorator
|
||||
export default class {}
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
// @target: ES6
|
||||
// @module: umd
|
||||
// @filename: a.ts
|
||||
export default class Foo {}
|
||||
|
||||
// @filename: b.ts
|
||||
export default function foo() {}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
// @filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
function Greet(x: {name: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
function Meet({name = 'world'}) {
|
||||
return <div>Hello, {name}</div>;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet name='world' />;
|
||||
// Error
|
||||
let b = <Greet naaame='world' />;
|
||||
|
||||
// OK
|
||||
let c = <Meet />;
|
||||
// OK
|
||||
let d = <Meet name='me' />;
|
||||
// Error
|
||||
let e = <Meet name={42} />;
|
||||
// Error
|
||||
let f = <Meet naaaaaaame='no' />;
|
||||
@ -0,0 +1,41 @@
|
||||
// @filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
import React = require('react');
|
||||
|
||||
function Greet(x: {name?: string}) {
|
||||
return <div>Hello, {x}</div>;
|
||||
}
|
||||
|
||||
class BigGreeter extends React.Component<{ name?: string }, {}> {
|
||||
render() {
|
||||
return <div></div>;
|
||||
}
|
||||
greeting: string;
|
||||
}
|
||||
|
||||
// OK
|
||||
let a = <Greet />;
|
||||
// OK - always valid to specify 'key'
|
||||
let b = <Greet key="k" />;
|
||||
// Error - not allowed to specify 'ref' on SFCs
|
||||
let c = <Greet ref="myRef" />;
|
||||
|
||||
|
||||
// OK - ref is valid for classes
|
||||
let d = <BigGreeter ref={x => x.greeting.substr(10)} />;
|
||||
// Error ('subtr' not on string)
|
||||
let e = <BigGreeter ref={x => x.greeting.subtr(10)} />;
|
||||
// Error (ref callback is contextually typed)
|
||||
let f = <BigGreeter ref={x => x.notARealProperty} />;
|
||||
|
||||
// OK - key is always valid
|
||||
let g = <BigGreeter key={100} />;
|
||||
|
||||
// OK - contextually typed intrinsic ref callback parameter
|
||||
let h = <div ref={x => x.innerText} />;
|
||||
// Error - property not on ontextually typed intrinsic ref callback parameter
|
||||
let i = <div ref={x => x.propertyNotOnHtmlDivElement} />;
|
||||
|
||||
17264
tests/lib/lib.d.ts
vendored
Normal file
17264
tests/lib/lib.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1034
tests/lib/react.d.ts
vendored
Normal file
1034
tests/lib/react.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@
|
||||
"no-null": true,
|
||||
"boolean-trivia": true,
|
||||
"type-operator-spacing": true,
|
||||
"prefer-const": true
|
||||
"prefer-const": true,
|
||||
"no-in-operator": true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user