mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'Microsoft/master' into tsconfigpath
This commit is contained in:
+3
-2
@@ -50,5 +50,6 @@ scripts/typings/
|
||||
coverage/
|
||||
internal/
|
||||
**/.DS_Store
|
||||
.settings/*
|
||||
!.settings/tasks.json
|
||||
.settings
|
||||
.vscode/*
|
||||
!.vscode/tasks.json
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@ doc
|
||||
scripts
|
||||
src
|
||||
tests
|
||||
Jakefile
|
||||
Jakefile.js
|
||||
.travis.yml
|
||||
.settings/
|
||||
.settings/
|
||||
.vscode/
|
||||
+1
-1
@@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr
|
||||
## Legal
|
||||
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
|
||||
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
|
||||
|
||||
## Housekeeping
|
||||
Your pull request should:
|
||||
|
||||
+3
-1
@@ -44,7 +44,9 @@
|
||||
"build": "npm run build:compiler && npm run build:tests",
|
||||
"build:compiler": "jake local",
|
||||
"build:tests": "jake tests",
|
||||
"clean": "jake clean"
|
||||
"clean": "jake clean",
|
||||
"jake": "jake",
|
||||
"setup-hooks": "node scripts/link-hooks.js"
|
||||
},
|
||||
"browser": {
|
||||
"buffer": false,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
npm run jake -- generate-diagnostics
|
||||
@@ -0,0 +1,20 @@
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var hooks = [
|
||||
"post-checkout"
|
||||
];
|
||||
|
||||
hooks.forEach(function (hook) {
|
||||
var hookInSourceControl = path.resolve(__dirname, "hooks", hook);
|
||||
|
||||
if (fs.existsSync(hookInSourceControl)) {
|
||||
var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", hook);
|
||||
|
||||
if (fs.existsSync(hookInHiddenDirectory)) {
|
||||
fs.unlinkSync(hookInHiddenDirectory);
|
||||
}
|
||||
|
||||
fs.linkSync(hookInSourceControl, hookInHiddenDirectory);
|
||||
}
|
||||
});
|
||||
+53
-50
@@ -44,6 +44,7 @@ namespace ts {
|
||||
|
||||
let compilerOptions = host.getCompilerOptions();
|
||||
let languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
|
||||
|
||||
let emitResolver = createResolver();
|
||||
|
||||
@@ -2293,10 +2294,17 @@ namespace ts {
|
||||
return type && (type.flags & TypeFlags.Any) !== 0;
|
||||
}
|
||||
|
||||
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
||||
// assigned by contextual typing.
|
||||
function getTypeForBindingElementParent(node: VariableLikeDeclaration) {
|
||||
let symbol = getSymbolOfNode(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
|
||||
}
|
||||
|
||||
// Return the inferred type for a binding element
|
||||
function getTypeForBindingElement(declaration: BindingElement): Type {
|
||||
let pattern = <BindingPattern>declaration.parent;
|
||||
let parentType = getTypeForVariableLikeDeclaration(<VariableLikeDeclaration>pattern.parent);
|
||||
let parentType = getTypeForBindingElementParent(<VariableLikeDeclaration>pattern.parent);
|
||||
// If parent has the unknown (error) type, then so does this binding element
|
||||
if (parentType === unknownType) {
|
||||
return unknownType;
|
||||
@@ -9162,10 +9170,24 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
|
||||
// the destructured type into the contained binding elements.
|
||||
function assignBindingElementTypes(node: VariableLikeDeclaration) {
|
||||
if (isBindingPattern(node.name)) {
|
||||
for (let element of (<BindingPattern>node.name).elements) {
|
||||
if (element.kind !== SyntaxKind.OmittedExpression) {
|
||||
getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
|
||||
assignBindingElementTypes(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function assignTypeToParameterAndFixTypeParameters(parameter: Symbol, contextualType: Type, mapper: TypeMapper) {
|
||||
let links = getSymbolLinks(parameter);
|
||||
if (!links.type) {
|
||||
links.type = instantiateType(contextualType, mapper);
|
||||
assignBindingElementTypes(<ParameterDeclaration>parameter.valueDeclaration);
|
||||
}
|
||||
else if (isInferentialContext(mapper)) {
|
||||
// Even if the parameter already has a type, it might be because it was given a type while
|
||||
@@ -12940,26 +12962,41 @@ namespace ts {
|
||||
if (!(nodeLinks.flags & NodeCheckFlags.EnumValuesComputed)) {
|
||||
let enumSymbol = getSymbolOfNode(node);
|
||||
let enumType = getDeclaredTypeOfSymbol(enumSymbol);
|
||||
let autoValue = 0;
|
||||
let autoValue = 0; // set to undefined when enum member is non-constant
|
||||
let ambient = isInAmbientContext(node);
|
||||
let enumIsConst = isConst(node);
|
||||
|
||||
forEach(node.members, member => {
|
||||
if (member.name.kind !== SyntaxKind.ComputedPropertyName && isNumericLiteralName((<Identifier>member.name).text)) {
|
||||
for (const member of node.members) {
|
||||
if (member.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
||||
}
|
||||
else if (isNumericLiteralName((<Identifier>member.name).text)) {
|
||||
error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
||||
}
|
||||
|
||||
const previousEnumMemberIsNonConstant = autoValue === undefined;
|
||||
|
||||
let initializer = member.initializer;
|
||||
if (initializer) {
|
||||
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
|
||||
}
|
||||
else if (ambient && !enumIsConst) {
|
||||
// In ambient enum declarations that specify no const modifier, enum member declarations
|
||||
// that omit a value are considered computed members (as opposed to having auto-incremented values assigned).
|
||||
autoValue = undefined;
|
||||
}
|
||||
else if (previousEnumMemberIsNonConstant) {
|
||||
// If the member declaration specifies no value, the member is considered a constant enum member.
|
||||
// If the member is the first member in the enum declaration, it is assigned the value zero.
|
||||
// Otherwise, it is assigned the value of the immediately preceding member plus one,
|
||||
// and an error occurs if the immediately preceding member is not a constant enum member
|
||||
error(member.name, Diagnostics.Enum_member_must_have_initializer);
|
||||
}
|
||||
|
||||
if (autoValue !== undefined) {
|
||||
getNodeLinks(member).enumMemberValue = autoValue++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed;
|
||||
}
|
||||
@@ -12975,11 +13012,11 @@ namespace ts {
|
||||
if (enumIsConst) {
|
||||
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
|
||||
}
|
||||
else if (!ambient) {
|
||||
else if (ambient) {
|
||||
error(initializer, Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
||||
}
|
||||
else {
|
||||
// Only here do we need to check that the initializer is assignable to the enum type.
|
||||
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
|
||||
// Also, we do not need to check this for ambients because there is already
|
||||
// a syntax error if it is not a constant.
|
||||
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
|
||||
}
|
||||
}
|
||||
@@ -13119,7 +13156,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Grammar checking
|
||||
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
|
||||
checkGrammarDecorators(node) || checkGrammarModifiers(node);
|
||||
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0);
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
@@ -13379,9 +13416,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (languageVersion >= ScriptTarget.ES6 && !isInAmbientContext(node)) {
|
||||
if (modulekind === ModuleKind.ES6 && !isInAmbientContext(node)) {
|
||||
// Import equals declaration is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead);
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13456,11 +13493,11 @@ namespace ts {
|
||||
checkExternalModuleExports(<SourceFile | ModuleDeclaration>container);
|
||||
|
||||
if (node.isExportEquals && !isInAmbientContext(node)) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// export assignment is deprecated in es6 or above
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
|
||||
if (modulekind === ModuleKind.ES6) {
|
||||
// export assignment is not supported in es6 modules
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead);
|
||||
}
|
||||
else if (compilerOptions.module === ModuleKind.System) {
|
||||
else if (modulekind === ModuleKind.System) {
|
||||
// system modules does not support export assignment
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
||||
}
|
||||
@@ -15619,40 +15656,6 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkGrammarEnumDeclaration(enumDecl: EnumDeclaration): boolean {
|
||||
let enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0;
|
||||
|
||||
let hasError = false;
|
||||
|
||||
// skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions.
|
||||
// since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members.
|
||||
if (!enumIsConst) {
|
||||
let inConstantEnumMemberSection = true;
|
||||
let inAmbientContext = isInAmbientContext(enumDecl);
|
||||
for (let node of enumDecl.members) {
|
||||
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
||||
// We want to perform checkComputedPropertyName for all computed properties, including
|
||||
// well known symbols.
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
||||
}
|
||||
else if (inAmbientContext) {
|
||||
if (node.initializer && !isIntegerLiteral(node.initializer)) {
|
||||
hasError = grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError;
|
||||
}
|
||||
}
|
||||
else if (node.initializer) {
|
||||
inConstantEnumMemberSection = isIntegerLiteral(node.initializer);
|
||||
}
|
||||
else if (!inConstantEnumMemberSection) {
|
||||
hasError = grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer) || hasError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasError;
|
||||
}
|
||||
|
||||
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
||||
return sourceFile.parseDiagnostics.length > 0;
|
||||
}
|
||||
|
||||
@@ -76,10 +76,11 @@ namespace ts {
|
||||
"amd": ModuleKind.AMD,
|
||||
"system": ModuleKind.System,
|
||||
"umd": ModuleKind.UMD,
|
||||
"es6": ModuleKind.ES6,
|
||||
},
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd,
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
|
||||
paramType: Diagnostics.KIND,
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd
|
||||
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
|
||||
},
|
||||
{
|
||||
name: "newLine",
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
"category": "Error",
|
||||
"code": 1063
|
||||
},
|
||||
"Ambient enum elements can only have integer literal initializers.": {
|
||||
"In ambient enum declarations member initializer must be constant expression.": {
|
||||
"category": "Error",
|
||||
"code": 1066
|
||||
},
|
||||
@@ -619,15 +619,15 @@
|
||||
"category": "Error",
|
||||
"code": 1200
|
||||
},
|
||||
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
|
||||
"Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": {
|
||||
"category": "Error",
|
||||
"code": 1202
|
||||
},
|
||||
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
|
||||
"Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.": {
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.": {
|
||||
"Cannot compile modules into 'es6' when targeting 'ES5' or lower.": {
|
||||
"category": "Error",
|
||||
"code": 1204
|
||||
},
|
||||
@@ -2109,7 +2109,7 @@
|
||||
"category": "Message",
|
||||
"code": 6015
|
||||
},
|
||||
"Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'": {
|
||||
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'": {
|
||||
"category": "Message",
|
||||
"code": 6016
|
||||
},
|
||||
@@ -2193,7 +2193,7 @@
|
||||
"category": "Error",
|
||||
"code": 6045
|
||||
},
|
||||
"Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'.": {
|
||||
"Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'.": {
|
||||
"category": "Error",
|
||||
"code": 6046
|
||||
},
|
||||
|
||||
+79
-56
@@ -64,6 +64,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
let compilerOptions = host.getCompilerOptions();
|
||||
let languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
|
||||
let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let newLine = host.getNewLine();
|
||||
@@ -188,6 +189,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
/** If removeComments is true, no leading-comments needed to be emitted **/
|
||||
let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
|
||||
|
||||
let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number) => void> = {
|
||||
[ModuleKind.ES6]: emitES6Module,
|
||||
[ModuleKind.AMD]: emitAMDModule,
|
||||
[ModuleKind.System]: emitSystemModule,
|
||||
[ModuleKind.UMD]: emitUMDModule,
|
||||
[ModuleKind.CommonJS]: emitCommonJSModule,
|
||||
};
|
||||
|
||||
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
|
||||
initializeEmitterWithSourceMaps();
|
||||
@@ -1425,6 +1434,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.CaseClause:
|
||||
@@ -1493,7 +1503,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
if (container) {
|
||||
if (container.kind === SyntaxKind.SourceFile) {
|
||||
// Identifier references module export
|
||||
if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) {
|
||||
if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) {
|
||||
write("exports.");
|
||||
}
|
||||
}
|
||||
@@ -1503,7 +1513,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(".");
|
||||
}
|
||||
}
|
||||
else if (languageVersion < ScriptTarget.ES6) {
|
||||
else if (modulekind !== ModuleKind.ES6) {
|
||||
let declaration = resolver.getReferencedImportDeclaration(node);
|
||||
if (declaration) {
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
@@ -3056,7 +3066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(getGeneratedNameForNode(container));
|
||||
write(".");
|
||||
}
|
||||
else if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) {
|
||||
else if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) {
|
||||
write("exports.");
|
||||
}
|
||||
}
|
||||
@@ -3076,7 +3086,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
if (node.parent.kind === SyntaxKind.SourceFile) {
|
||||
Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment);
|
||||
// only allow export default at a source file level
|
||||
if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) {
|
||||
if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) {
|
||||
if (!currentSourceFile.symbol.exports["___esModule"]) {
|
||||
if (languageVersion === ScriptTarget.ES5) {
|
||||
// default value of configurable, enumerable, writable are `false`.
|
||||
@@ -3098,7 +3108,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emitStart(node);
|
||||
|
||||
// emit call to exporter only for top level nodes
|
||||
if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) {
|
||||
if (modulekind === ModuleKind.System && node.parent === currentSourceFile) {
|
||||
// emit export default <smth> as
|
||||
// export("default", <smth>)
|
||||
write(`${exportFunctionForFile}("`);
|
||||
@@ -3134,7 +3144,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitExportMemberAssignments(name: Identifier) {
|
||||
if (compilerOptions.module === ModuleKind.System) {
|
||||
if (modulekind === ModuleKind.System) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3154,7 +3164,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void {
|
||||
Debug.assert(compilerOptions.module === ModuleKind.System);
|
||||
Debug.assert(modulekind === ModuleKind.System);
|
||||
|
||||
if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) {
|
||||
return;
|
||||
@@ -3491,7 +3501,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
function isES6ExportedDeclaration(node: Node) {
|
||||
return !!(node.flags & NodeFlags.Export) &&
|
||||
languageVersion >= ScriptTarget.ES6 &&
|
||||
modulekind === ModuleKind.ES6 &&
|
||||
node.parent.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
@@ -4520,8 +4530,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
write("class");
|
||||
|
||||
// check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated.
|
||||
if ((node.name || !(node.flags & NodeFlags.Default)) && !thisNodeIsDecorated) {
|
||||
// emit name if
|
||||
// - node has a name
|
||||
// - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel)
|
||||
if ((node.name || (node.flags & NodeFlags.Default && languageVersion < ScriptTarget.ES6)) && !thisNodeIsDecorated) {
|
||||
write(" ");
|
||||
emitDeclarationName(node);
|
||||
}
|
||||
@@ -5257,7 +5269,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(";");
|
||||
}
|
||||
if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) {
|
||||
if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
// write the call to exporter for enum
|
||||
writeLine();
|
||||
write(`${exportFunctionForFile}("`);
|
||||
@@ -5379,7 +5391,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(" = {}));");
|
||||
emitEnd(node);
|
||||
if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) {
|
||||
if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) {
|
||||
writeLine();
|
||||
write(`${exportFunctionForFile}("`);
|
||||
emitDeclarationName(node);
|
||||
@@ -5443,7 +5455,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitImportDeclaration(node: ImportDeclaration) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (modulekind !== ModuleKind.ES6) {
|
||||
return emitExternalImportDeclaration(node);
|
||||
}
|
||||
|
||||
@@ -5494,7 +5506,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
let namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
|
||||
if (compilerOptions.module !== ModuleKind.AMD) {
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
emitLeadingComments(node);
|
||||
emitStart(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
@@ -5606,15 +5618,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitExportDeclaration(node: ExportDeclaration) {
|
||||
Debug.assert(compilerOptions.module !== ModuleKind.System);
|
||||
Debug.assert(modulekind !== ModuleKind.System);
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (modulekind !== ModuleKind.ES6) {
|
||||
if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) {
|
||||
emitStart(node);
|
||||
let generatedName = getGeneratedNameForNode(node);
|
||||
if (node.exportClause) {
|
||||
// export { x, y, ... } from "foo"
|
||||
if (compilerOptions.module !== ModuleKind.AMD) {
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
write("var ");
|
||||
write(generatedName);
|
||||
write(" = ");
|
||||
@@ -5641,7 +5653,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// export * from "foo"
|
||||
writeLine();
|
||||
write("__export(");
|
||||
if (compilerOptions.module !== ModuleKind.AMD) {
|
||||
if (modulekind !== ModuleKind.AMD) {
|
||||
emitRequire(getExternalModuleName(node));
|
||||
}
|
||||
else {
|
||||
@@ -5674,7 +5686,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitExportOrImportSpecifierList(specifiers: ImportOrExportSpecifier[], shouldEmit: (node: Node) => boolean) {
|
||||
Debug.assert(languageVersion >= ScriptTarget.ES6);
|
||||
Debug.assert(modulekind === ModuleKind.ES6);
|
||||
|
||||
let needsComma = false;
|
||||
for (let specifier of specifiers) {
|
||||
@@ -5694,7 +5706,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
function emitExportAssignment(node: ExportAssignment) {
|
||||
if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
if (modulekind === ModuleKind.ES6) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
write("export default ");
|
||||
@@ -5709,7 +5721,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
else {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
if (compilerOptions.module === ModuleKind.System) {
|
||||
if (modulekind === ModuleKind.System) {
|
||||
write(`${exportFunctionForFile}("default",`);
|
||||
emit(node.expression);
|
||||
write(")");
|
||||
@@ -6155,7 +6167,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function isCurrentFileSystemExternalModule() {
|
||||
return compilerOptions.module === ModuleKind.System && isExternalModule(currentSourceFile);
|
||||
return modulekind === ModuleKind.System && isExternalModule(currentSourceFile);
|
||||
}
|
||||
|
||||
function emitSystemModuleBody(node: SourceFile, dependencyGroups: DependencyGroup[], startIndex: number): void {
|
||||
@@ -6395,19 +6407,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write("});");
|
||||
}
|
||||
|
||||
function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) {
|
||||
// An AMD define function has the following shape:
|
||||
// define(id?, dependencies?, factory);
|
||||
//
|
||||
// This has the shape of
|
||||
// define(name, ["module1", "module2"], function (module1Alias) {
|
||||
// The location of the alias in the parameter list in the factory function needs to
|
||||
// match the position of the module name in the dependency list.
|
||||
//
|
||||
// To ensure this is true in cases of modules with no aliases, e.g.:
|
||||
// `import "module"` or `<amd-dependency path= "a.css" />`
|
||||
// we need to add modules without alias names to the end of the dependencies list
|
||||
interface AMDDependencyNames {
|
||||
aliasedModuleNames: string[];
|
||||
unaliasedModuleNames: string[];
|
||||
importAliasNames: string[];
|
||||
}
|
||||
|
||||
function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean): AMDDependencyNames {
|
||||
// names of modules with corresponding parameter in the factory function
|
||||
let aliasedModuleNames: string[] = [];
|
||||
// names of modules with no corresponding parameters in factory function
|
||||
@@ -6442,6 +6448,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
return { aliasedModuleNames, unaliasedModuleNames, importAliasNames };
|
||||
}
|
||||
|
||||
function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) {
|
||||
// An AMD define function has the following shape:
|
||||
// define(id?, dependencies?, factory);
|
||||
//
|
||||
// This has the shape of
|
||||
// define(name, ["module1", "module2"], function (module1Alias) {
|
||||
// The location of the alias in the parameter list in the factory function needs to
|
||||
// match the position of the module name in the dependency list.
|
||||
//
|
||||
// To ensure this is true in cases of modules with no aliases, e.g.:
|
||||
// `import "module"` or `<amd-dependency path= "a.css" />`
|
||||
// we need to add modules without alias names to the end of the dependencies list
|
||||
|
||||
let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies);
|
||||
emitAMDDependencyList(dependencyNames);
|
||||
write(", ");
|
||||
emitAMDFactoryHeader(dependencyNames);
|
||||
}
|
||||
|
||||
function emitAMDDependencyList({ aliasedModuleNames, unaliasedModuleNames }: AMDDependencyNames) {
|
||||
write("[\"require\", \"exports\"");
|
||||
if (aliasedModuleNames.length) {
|
||||
write(", ");
|
||||
@@ -6451,11 +6480,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(", ");
|
||||
write(unaliasedModuleNames.join(", "));
|
||||
}
|
||||
write("], function (require, exports");
|
||||
write("]");
|
||||
}
|
||||
|
||||
function emitAMDFactoryHeader({ importAliasNames }: AMDDependencyNames) {
|
||||
write("function (require, exports");
|
||||
if (importAliasNames.length) {
|
||||
write(", ");
|
||||
write(importAliasNames.join(", "));
|
||||
}
|
||||
write(") {");
|
||||
}
|
||||
|
||||
function emitAMDModule(node: SourceFile, startIndex: number) {
|
||||
@@ -6468,7 +6502,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write("\"" + node.moduleName + "\", ");
|
||||
}
|
||||
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
|
||||
write(") {");
|
||||
increaseIndent();
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
@@ -6494,17 +6527,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false);
|
||||
|
||||
// Module is detected first to support Browserify users that load into a browser with an AMD loader
|
||||
writeLines(`(function (deps, factory) {
|
||||
writeLines(`(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(deps, factory);
|
||||
}
|
||||
define(`);
|
||||
emitAMDDependencyList(dependencyNames);
|
||||
write(", factory);");
|
||||
writeLines(` }
|
||||
})(`);
|
||||
emitAMDDependencies(node, false);
|
||||
write(") {");
|
||||
emitAMDFactoryHeader(dependencyNames);
|
||||
increaseIndent();
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
@@ -6713,21 +6749,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
emitES6Module(node, startIndex);
|
||||
}
|
||||
else if (compilerOptions.module === ModuleKind.AMD) {
|
||||
emitAMDModule(node, startIndex);
|
||||
}
|
||||
else if (compilerOptions.module === ModuleKind.System) {
|
||||
emitSystemModule(node, startIndex);
|
||||
}
|
||||
else if (compilerOptions.module === ModuleKind.UMD) {
|
||||
emitUMDModule(node, startIndex);
|
||||
}
|
||||
else {
|
||||
emitCommonJSModule(node, startIndex);
|
||||
}
|
||||
let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS];
|
||||
emitModule(node, startIndex);
|
||||
}
|
||||
else {
|
||||
externalImports = undefined;
|
||||
|
||||
+17
-2
@@ -4809,7 +4809,7 @@ namespace ts {
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.ClassKeyword);
|
||||
node.name = parseOptionalIdentifier();
|
||||
node.name = parseNameOfClassDeclarationOrExpression();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true);
|
||||
|
||||
@@ -4825,7 +4825,22 @@ namespace ts {
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseNameOfClassDeclarationOrExpression(): Identifier {
|
||||
// implements is a future reserved word so
|
||||
// 'class implements' might mean either
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function isImplementsClause() {
|
||||
return token === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword)
|
||||
}
|
||||
|
||||
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
|
||||
+55
-51
@@ -568,7 +568,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string) {
|
||||
return filesByName.get(fileName);
|
||||
// first try to use file name as is to find file
|
||||
// then try to convert relative file name to absolute and use it to retrieve source file
|
||||
return filesByName.get(fileName) || filesByName.get(getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()));
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(
|
||||
@@ -775,60 +777,62 @@ namespace ts {
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
if (filesByName.contains(canonicalName)) {
|
||||
if (filesByName.contains(fileName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false);
|
||||
return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false);
|
||||
}
|
||||
else {
|
||||
let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
let canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
|
||||
if (filesByName.contains(canonicalAbsolutePath)) {
|
||||
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
filesByName.set(canonicalName, file);
|
||||
if (file) {
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
// Set the source file for normalized absolute path
|
||||
filesByName.set(canonicalAbsolutePath, file);
|
||||
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath);
|
||||
}
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
processImportedModules(file, basePath);
|
||||
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
files.unshift(file);
|
||||
}
|
||||
else {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
if (filesByName.contains(normalizedAbsolutePath)) {
|
||||
const file = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true);
|
||||
// we don't have resolution for this relative file name but the match was found by absolute file name
|
||||
// store resolution for relative name as well
|
||||
filesByName.set(fileName, file);
|
||||
return file;
|
||||
}
|
||||
|
||||
function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile {
|
||||
let file = filesByName.get(canonicalName);
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
|
||||
filesByName.set(fileName, file);
|
||||
if (file) {
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
// Set the source file for normalized absolute path
|
||||
filesByName.set(normalizedAbsolutePath, file);
|
||||
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath);
|
||||
}
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
processImportedModules(file, basePath);
|
||||
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
files.unshift(file);
|
||||
}
|
||||
else {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
|
||||
function getSourceFileFromCache(fileName: string, useAbsolutePath: boolean): SourceFile {
|
||||
let file = filesByName.get(fileName);
|
||||
if (file && host.useCaseSensitiveFileNames()) {
|
||||
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (canonicalName !== sourceFileName) {
|
||||
if (normalizeSlashes(fileName) !== normalizeSlashes(sourceFileName)) {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
@@ -1022,9 +1026,9 @@ namespace ts {
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
|
||||
// Cannot specify module gen target when in es6 or above
|
||||
if (options.module && languageVersion >= ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
|
||||
+7
-19
@@ -739,18 +739,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isIdentifierStart(ch: number): boolean {
|
||||
return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
|
||||
ch === CharacterCodes.$ || ch === CharacterCodes._ ||
|
||||
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch, languageVersion);
|
||||
}
|
||||
|
||||
function isIdentifierPart(ch: number): boolean {
|
||||
return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
|
||||
ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ ||
|
||||
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
|
||||
}
|
||||
|
||||
function scanNumber(): number {
|
||||
let start = pos;
|
||||
while (isDigit(text.charCodeAt(pos))) pos++;
|
||||
@@ -1064,12 +1052,12 @@ namespace ts {
|
||||
let start = pos;
|
||||
while (pos < end) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
if (isIdentifierPart(ch)) {
|
||||
if (isIdentifierPart(ch, languageVersion)) {
|
||||
pos++;
|
||||
}
|
||||
else if (ch === CharacterCodes.backslash) {
|
||||
ch = peekUnicodeEscape();
|
||||
if (!(ch >= 0 && isIdentifierPart(ch))) {
|
||||
if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
|
||||
break;
|
||||
}
|
||||
result += text.substring(start, pos);
|
||||
@@ -1439,7 +1427,7 @@ namespace ts {
|
||||
return pos++, token = SyntaxKind.AtToken;
|
||||
case CharacterCodes.backslash:
|
||||
let cookedChar = peekUnicodeEscape();
|
||||
if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
|
||||
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
|
||||
pos += 6;
|
||||
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
|
||||
return token = getIdentifierToken();
|
||||
@@ -1447,9 +1435,9 @@ namespace ts {
|
||||
error(Diagnostics.Invalid_character);
|
||||
return pos++, token = SyntaxKind.Unknown;
|
||||
default:
|
||||
if (isIdentifierStart(ch)) {
|
||||
if (isIdentifierStart(ch, languageVersion)) {
|
||||
pos++;
|
||||
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) pos++;
|
||||
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++;
|
||||
tokenValue = text.substring(tokenPos, pos);
|
||||
if (ch === CharacterCodes.backslash) {
|
||||
tokenValue += scanIdentifierParts();
|
||||
@@ -1536,7 +1524,7 @@ namespace ts {
|
||||
p++;
|
||||
}
|
||||
|
||||
while (p < end && isIdentifierPart(text.charCodeAt(p))) {
|
||||
while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
|
||||
p++;
|
||||
}
|
||||
pos = p;
|
||||
@@ -1599,7 +1587,7 @@ namespace ts {
|
||||
let firstCharPosition = pos;
|
||||
while (pos < end) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) {
|
||||
if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) {
|
||||
pos++;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2076,6 +2076,7 @@ namespace ts {
|
||||
AMD = 2,
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
ES6 = 5,
|
||||
}
|
||||
|
||||
export const enum JsxEmit {
|
||||
|
||||
@@ -621,7 +621,7 @@ namespace ts {
|
||||
return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression);
|
||||
}
|
||||
|
||||
export function isFunctionLike(node: Node): boolean {
|
||||
export function isFunctionLike(node: Node): node is FunctionLikeDeclaration {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
|
||||
@@ -1908,7 +1908,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
if (actual.newText !== expected.newText) {
|
||||
this.raiseError(name + ' failed - expected insertion:\n' + expected.newText + '\nactual insertion:\n' + actual.newText);
|
||||
this.raiseError(name + ' failed - expected insertion:\n' + this.clarifyNewlines(expected.newText) + '\nactual insertion:\n' + this.clarifyNewlines(actual.newText));
|
||||
}
|
||||
|
||||
if (actual.caretOffset !== expected.caretOffset) {
|
||||
@@ -1917,6 +1917,13 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private clarifyNewlines(str: string) {
|
||||
return str.replace(/\r?\n/g, lineEnding => {
|
||||
const representation = lineEnding === "\r\n" ? "CRLF" : "LF";
|
||||
return "# - " + representation + lineEnding;
|
||||
});
|
||||
}
|
||||
|
||||
public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) {
|
||||
this.taoInvalidReason = "verifyMatchingBracePosition NYI";
|
||||
|
||||
|
||||
@@ -3,8 +3,14 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts.formatting {
|
||||
let scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
|
||||
|
||||
const standardScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.Standard);
|
||||
const jsxScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.JSX);
|
||||
|
||||
/**
|
||||
* Scanner that is currently used for formatting
|
||||
*/
|
||||
let scanner: Scanner;
|
||||
|
||||
export interface FormattingScanner {
|
||||
advance(): void;
|
||||
isOnToken(): boolean;
|
||||
@@ -22,6 +28,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
|
||||
Debug.assert(scanner === undefined);
|
||||
scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner;
|
||||
|
||||
scanner.setText(sourceFile.text);
|
||||
scanner.setTextPos(startPos);
|
||||
@@ -40,12 +48,17 @@ namespace ts.formatting {
|
||||
isOnToken: isOnToken,
|
||||
lastTrailingTriviaWasNewLine: () => wasNewLine,
|
||||
close: () => {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
lastTokenInfo = undefined;
|
||||
scanner.setText(undefined);
|
||||
scanner = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function advance(): void {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
lastTokenInfo = undefined;
|
||||
let isStarted = scanner.getStartPos() !== startPos;
|
||||
|
||||
@@ -138,6 +151,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function readTokenInfo(n: Node): TokenInfo {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
if (!isOnToken()) {
|
||||
// scanner is not on the token (either advance was not called yet or scanner is already past the end position)
|
||||
return {
|
||||
@@ -245,6 +260,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function isOnToken(): boolean {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
let startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos();
|
||||
return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current);
|
||||
|
||||
+91
-11
@@ -3549,6 +3549,9 @@ namespace ts {
|
||||
if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) {
|
||||
return <JsxOpeningLikeElement>parent;
|
||||
}
|
||||
else if (parent.kind === SyntaxKind.JsxAttribute) {
|
||||
return <JsxOpeningLikeElement>parent.parent;
|
||||
}
|
||||
break;
|
||||
|
||||
// The context token is the closing } or " of an attribute, which means
|
||||
@@ -6997,8 +7000,12 @@ namespace ts {
|
||||
* Checks if position points to a valid position to add JSDoc comments, and if so,
|
||||
* returns the appropriate template. Otherwise returns an empty string.
|
||||
* Valid positions are
|
||||
* - outside of comments, statements, and expressions, and
|
||||
* - preceding a function declaration.
|
||||
* - outside of comments, statements, and expressions, and
|
||||
* - preceding a:
|
||||
* - function/constructor/method declaration
|
||||
* - class declarations
|
||||
* - variable statements
|
||||
* - namespace declarations
|
||||
*
|
||||
* Hosts should ideally check that:
|
||||
* - The line is all whitespace up to 'position' before performing the insertion.
|
||||
@@ -7025,16 +7032,37 @@ namespace ts {
|
||||
}
|
||||
|
||||
// TODO: add support for:
|
||||
// - methods
|
||||
// - constructors
|
||||
// - class decls
|
||||
let containingFunction = <FunctionDeclaration>getAncestor(tokenAtPos, SyntaxKind.FunctionDeclaration);
|
||||
// - enums/enum members
|
||||
// - interfaces
|
||||
// - property declarations
|
||||
// - potentially property assignments
|
||||
let commentOwner: Node;
|
||||
findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) {
|
||||
switch (commentOwner.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.VariableStatement:
|
||||
break findOwner;
|
||||
case SyntaxKind.SourceFile:
|
||||
return undefined;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// If in walking up the tree, we hit a a nested namespace declaration,
|
||||
// then we must be somewhere within a dotted namespace name; however we don't
|
||||
// want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'.
|
||||
if (commentOwner.parent.kind === SyntaxKind.ModuleDeclaration) {
|
||||
return undefined;
|
||||
}
|
||||
break findOwner;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containingFunction || containingFunction.getStart() < position) {
|
||||
if (!commentOwner || commentOwner.getStart() < position) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let parameters = containingFunction.parameters;
|
||||
let parameters = getParametersForJsDocOwningNode(commentOwner);
|
||||
let posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position);
|
||||
let lineStart = sourceFile.getLineStarts()[posLineAndChar.line];
|
||||
|
||||
@@ -7043,9 +7071,15 @@ namespace ts {
|
||||
// TODO: call a helper method instead once PR #4133 gets merged in.
|
||||
const newLine = host.getNewLine ? host.getNewLine() : "\r\n";
|
||||
|
||||
let docParams = parameters.reduce((prev, cur, index) =>
|
||||
prev +
|
||||
indentationStr + " * @param " + (cur.name.kind === SyntaxKind.Identifier ? (<Identifier>cur.name).text : "param" + index) + newLine, "");
|
||||
let docParams = "";
|
||||
for (let i = 0, numParams = parameters.length; i < numParams; i++) {
|
||||
const currentName = parameters[i].name;
|
||||
const paramName = currentName.kind === SyntaxKind.Identifier ?
|
||||
(<Identifier>currentName).text :
|
||||
"param" + i;
|
||||
|
||||
docParams += `${indentationStr} * @param ${paramName}${newLine}`;
|
||||
}
|
||||
|
||||
// A doc comment consists of the following
|
||||
// * The opening comment line
|
||||
@@ -7065,6 +7099,52 @@ namespace ts {
|
||||
return { newText: result, caretOffset: preamble.length };
|
||||
}
|
||||
|
||||
function getParametersForJsDocOwningNode(commentOwner: Node): ParameterDeclaration[] {
|
||||
if (isFunctionLike(commentOwner)) {
|
||||
return commentOwner.parameters;
|
||||
}
|
||||
|
||||
if (commentOwner.kind === SyntaxKind.VariableStatement) {
|
||||
const varStatement = <VariableStatement>commentOwner;
|
||||
const varDeclarations = varStatement.declarationList.declarations;
|
||||
|
||||
if (varDeclarations.length === 1 && varDeclarations[0].initializer) {
|
||||
return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer);
|
||||
}
|
||||
}
|
||||
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Digs into an an initializer or RHS operand of an assignment operation
|
||||
* to get the parameters of an apt signature corresponding to a
|
||||
* function expression or a class expression.
|
||||
*
|
||||
* @param rightHandSide the expression which may contain an appropriate set of parameters
|
||||
* @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'.
|
||||
*/
|
||||
function getParametersFromRightHandSideOfAssignment(rightHandSide: Expression): ParameterDeclaration[] {
|
||||
while (rightHandSide.kind === SyntaxKind.ParenthesizedExpression) {
|
||||
rightHandSide = (<ParenthesizedExpression>rightHandSide).expression;
|
||||
}
|
||||
|
||||
switch (rightHandSide.kind) {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return (<FunctionExpression>rightHandSide).parameters;
|
||||
case SyntaxKind.ClassExpression:
|
||||
for (let member of (<ClassExpression>rightHandSide).members) {
|
||||
if (member.kind === SyntaxKind.Constructor) {
|
||||
return (<ConstructorDeclaration>member).parameters;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
// Note: while getting todo comments seems like a syntactic operation, we actually
|
||||
// treat it as a semantic operation here. This is because we expect our host to call
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
tests/cases/compiler/ambientEnum1.ts(2,9): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/compiler/ambientEnum1.ts(7,9): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/compiler/ambientEnum1.ts(7,13): error TS1066: In ambient enum declarations member initializer must be constant expression.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ambientEnum1.ts (2 errors) ====
|
||||
==== tests/cases/compiler/ambientEnum1.ts (1 errors) ====
|
||||
declare enum E1 {
|
||||
y = 4.23
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
|
||||
// Ambient enum with computer member
|
||||
declare enum E2 {
|
||||
x = 'foo'.length
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1066: In ambient enum declarations member initializer must be constant expression.
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(7,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(8,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts (4 errors) ====
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
a = 10,
|
||||
b = 10 + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
c = b,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
d = (c) + 1,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
e = 10 << 2 * 8,
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts ===
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
>E : Symbol(E, Decl(ambientEnumDeclaration1.ts, 0, 0))
|
||||
|
||||
a = 10,
|
||||
>a : Symbol(E.a, Decl(ambientEnumDeclaration1.ts, 2, 16))
|
||||
|
||||
b = 10 + 1,
|
||||
>b : Symbol(E.b, Decl(ambientEnumDeclaration1.ts, 3, 11))
|
||||
|
||||
c = b,
|
||||
>c : Symbol(E.c, Decl(ambientEnumDeclaration1.ts, 4, 15))
|
||||
>b : Symbol(E.b, Decl(ambientEnumDeclaration1.ts, 3, 11))
|
||||
|
||||
d = (c) + 1,
|
||||
>d : Symbol(E.d, Decl(ambientEnumDeclaration1.ts, 5, 10))
|
||||
>c : Symbol(E.c, Decl(ambientEnumDeclaration1.ts, 4, 15))
|
||||
|
||||
e = 10 << 2 * 8,
|
||||
>e : Symbol(E.e, Decl(ambientEnumDeclaration1.ts, 6, 16))
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts ===
|
||||
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions.
|
||||
|
||||
declare enum E {
|
||||
>E : E
|
||||
|
||||
a = 10,
|
||||
>a : E
|
||||
>10 : number
|
||||
|
||||
b = 10 + 1,
|
||||
>b : E
|
||||
>10 + 1 : number
|
||||
>10 : number
|
||||
>1 : number
|
||||
|
||||
c = b,
|
||||
>c : E
|
||||
>b : E
|
||||
|
||||
d = (c) + 1,
|
||||
>d : E
|
||||
>(c) + 1 : number
|
||||
>(c) : E
|
||||
>c : E
|
||||
>1 : number
|
||||
|
||||
e = 10 << 2 * 8,
|
||||
>e : E
|
||||
>10 << 2 * 8 : number
|
||||
>10 : number
|
||||
>2 * 8 : number
|
||||
>2 : number
|
||||
>8 : number
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
tests/cases/compiler/ambientEnumElementInitializer3.ts(2,2): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ambientEnumElementInitializer3.ts (1 errors) ====
|
||||
declare enum E {
|
||||
e = 3.3 // Decimal
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/ambientEnumElementInitializer3.ts ===
|
||||
declare enum E {
|
||||
>E : Symbol(E, Decl(ambientEnumElementInitializer3.ts, 0, 0))
|
||||
|
||||
e = 3.3 // Decimal
|
||||
>e : Symbol(E.e, Decl(ambientEnumElementInitializer3.ts, 0, 16))
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/ambientEnumElementInitializer3.ts ===
|
||||
declare enum E {
|
||||
>E : E
|
||||
|
||||
e = 3.3 // Decimal
|
||||
>e : E
|
||||
>3.3 : number
|
||||
}
|
||||
@@ -2,8 +2,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initialize
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(6,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(29,9): error TS1066: In ambient enum declarations member initializer must be constant expression.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
@@ -16,7 +15,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient m
|
||||
tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
|
||||
==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ====
|
||||
==== tests/cases/conformance/ambient/ambientErrors.ts (15 errors) ====
|
||||
// Ambient variable with an initializer
|
||||
declare var x = 4;
|
||||
~
|
||||
@@ -49,15 +48,13 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export
|
||||
// Ambient enum with non - integer literal constant member
|
||||
declare enum E1 {
|
||||
y = 4.23
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
|
||||
// Ambient enum with computer member
|
||||
declare enum E2 {
|
||||
x = 'foo'.length
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1066: In ambient enum declarations member initializer must be constant expression.
|
||||
}
|
||||
|
||||
// Ambient module with initializers for values, bodies for functions / classes
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [tests/cases/conformance/expressions/asOperator/asOperator4.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
|
||||
export function foo() { }
|
||||
|
||||
//// [bar.ts]
|
||||
import { foo } from './foo';
|
||||
|
||||
// These should emit identically
|
||||
<any>foo;
|
||||
(foo as any);
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
function foo() { }
|
||||
exports.foo = foo;
|
||||
//// [bar.js]
|
||||
var foo_1 = require('./foo');
|
||||
// These should emit identically
|
||||
foo_1.foo;
|
||||
foo_1.foo;
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/expressions/asOperator/foo.ts ===
|
||||
|
||||
export function foo() { }
|
||||
>foo : Symbol(foo, Decl(foo.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/expressions/asOperator/bar.ts ===
|
||||
import { foo } from './foo';
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
// These should emit identically
|
||||
<any>foo;
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
(foo as any);
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/expressions/asOperator/foo.ts ===
|
||||
|
||||
export function foo() { }
|
||||
>foo : () => void
|
||||
|
||||
=== tests/cases/conformance/expressions/asOperator/bar.ts ===
|
||||
import { foo } from './foo';
|
||||
>foo : () => void
|
||||
|
||||
// These should emit identically
|
||||
<any>foo;
|
||||
><any>foo : any
|
||||
>foo : () => void
|
||||
|
||||
(foo as any);
|
||||
>(foo as any) : any
|
||||
>foo as any : any
|
||||
>foo : () => void
|
||||
|
||||
@@ -7,7 +7,7 @@ c.c;
|
||||
|
||||
|
||||
//// [classExpressionES63.js]
|
||||
let C = class class_1 extends class class_2 extends class class_3 {
|
||||
let C = class extends class extends class {
|
||||
constructor() {
|
||||
this.a = 1;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
@@ -20,12 +18,9 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ====
|
||||
==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ====
|
||||
///<reference path='constDeclarations_access_1.ts'/>
|
||||
import m = require('constDeclarations_access_1');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
// Errors
|
||||
m.x = 1;
|
||||
~~~
|
||||
|
||||
@@ -49,35 +49,39 @@ m.x.toString();
|
||||
|
||||
|
||||
//// [constDeclarations_access_1.js]
|
||||
export const x = 0;
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.x = 0;
|
||||
});
|
||||
//// [constDeclarations_access_2.js]
|
||||
// Errors
|
||||
m.x = 1;
|
||||
m.x += 2;
|
||||
m.x -= 3;
|
||||
m.x *= 4;
|
||||
m.x /= 5;
|
||||
m.x %= 6;
|
||||
m.x <<= 7;
|
||||
m.x >>= 8;
|
||||
m.x >>>= 9;
|
||||
m.x &= 10;
|
||||
m.x |= 11;
|
||||
m.x ^= 12;
|
||||
m;
|
||||
m.x++;
|
||||
m.x--;
|
||||
++m.x;
|
||||
--m.x;
|
||||
++((m.x));
|
||||
m["x"] = 0;
|
||||
// OK
|
||||
var a = m.x + 1;
|
||||
function f(v) { }
|
||||
f(m.x);
|
||||
if (m.x) { }
|
||||
m.x;
|
||||
(m.x);
|
||||
-m.x;
|
||||
+m.x;
|
||||
m.x.toString();
|
||||
define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) {
|
||||
// Errors
|
||||
m.x = 1;
|
||||
m.x += 2;
|
||||
m.x -= 3;
|
||||
m.x *= 4;
|
||||
m.x /= 5;
|
||||
m.x %= 6;
|
||||
m.x <<= 7;
|
||||
m.x >>= 8;
|
||||
m.x >>>= 9;
|
||||
m.x &= 10;
|
||||
m.x |= 11;
|
||||
m.x ^= 12;
|
||||
m;
|
||||
m.x++;
|
||||
m.x--;
|
||||
++m.x;
|
||||
--m.x;
|
||||
++((m.x));
|
||||
m["x"] = 0;
|
||||
// OK
|
||||
var a = m.x + 1;
|
||||
function f(v) { }
|
||||
f(m.x);
|
||||
if (m.x) { }
|
||||
m.x;
|
||||
(m.x);
|
||||
-m.x;
|
||||
+m.x;
|
||||
m.x.toString();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [destructuringWithGenericParameter.ts]
|
||||
class GenericClass<T> {
|
||||
payload: T;
|
||||
}
|
||||
|
||||
var genericObject = new GenericClass<{ greeting: string }>();
|
||||
|
||||
function genericFunction<T>(object: GenericClass<T>, callback: (payload: T) => void) {
|
||||
callback(object.payload);
|
||||
}
|
||||
|
||||
genericFunction(genericObject, ({greeting}) => {
|
||||
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
|
||||
});
|
||||
|
||||
|
||||
//// [destructuringWithGenericParameter.js]
|
||||
var GenericClass = (function () {
|
||||
function GenericClass() {
|
||||
}
|
||||
return GenericClass;
|
||||
})();
|
||||
var genericObject = new GenericClass();
|
||||
function genericFunction(object, callback) {
|
||||
callback(object.payload);
|
||||
}
|
||||
genericFunction(genericObject, function (_a) {
|
||||
var greeting = _a.greeting;
|
||||
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/compiler/destructuringWithGenericParameter.ts ===
|
||||
class GenericClass<T> {
|
||||
>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 0, 19))
|
||||
|
||||
payload: T;
|
||||
>payload : Symbol(payload, Decl(destructuringWithGenericParameter.ts, 0, 23))
|
||||
>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 0, 19))
|
||||
}
|
||||
|
||||
var genericObject = new GenericClass<{ greeting: string }>();
|
||||
>genericObject : Symbol(genericObject, Decl(destructuringWithGenericParameter.ts, 4, 3))
|
||||
>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0))
|
||||
>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 4, 38))
|
||||
|
||||
function genericFunction<T>(object: GenericClass<T>, callback: (payload: T) => void) {
|
||||
>genericFunction : Symbol(genericFunction, Decl(destructuringWithGenericParameter.ts, 4, 61))
|
||||
>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25))
|
||||
>object : Symbol(object, Decl(destructuringWithGenericParameter.ts, 6, 28))
|
||||
>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25))
|
||||
>callback : Symbol(callback, Decl(destructuringWithGenericParameter.ts, 6, 52))
|
||||
>payload : Symbol(payload, Decl(destructuringWithGenericParameter.ts, 6, 64))
|
||||
>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25))
|
||||
|
||||
callback(object.payload);
|
||||
>callback : Symbol(callback, Decl(destructuringWithGenericParameter.ts, 6, 52))
|
||||
>object.payload : Symbol(GenericClass.payload, Decl(destructuringWithGenericParameter.ts, 0, 23))
|
||||
>object : Symbol(object, Decl(destructuringWithGenericParameter.ts, 6, 28))
|
||||
>payload : Symbol(GenericClass.payload, Decl(destructuringWithGenericParameter.ts, 0, 23))
|
||||
}
|
||||
|
||||
genericFunction(genericObject, ({greeting}) => {
|
||||
>genericFunction : Symbol(genericFunction, Decl(destructuringWithGenericParameter.ts, 4, 61))
|
||||
>genericObject : Symbol(genericObject, Decl(destructuringWithGenericParameter.ts, 4, 3))
|
||||
>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 10, 33))
|
||||
|
||||
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
|
||||
>s : Symbol(s, Decl(destructuringWithGenericParameter.ts, 11, 7))
|
||||
>greeting.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, 402, 26))
|
||||
>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 10, 33))
|
||||
>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, 402, 26))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/compiler/destructuringWithGenericParameter.ts ===
|
||||
class GenericClass<T> {
|
||||
>GenericClass : GenericClass<T>
|
||||
>T : T
|
||||
|
||||
payload: T;
|
||||
>payload : T
|
||||
>T : T
|
||||
}
|
||||
|
||||
var genericObject = new GenericClass<{ greeting: string }>();
|
||||
>genericObject : GenericClass<{ greeting: string; }>
|
||||
>new GenericClass<{ greeting: string }>() : GenericClass<{ greeting: string; }>
|
||||
>GenericClass : typeof GenericClass
|
||||
>greeting : string
|
||||
|
||||
function genericFunction<T>(object: GenericClass<T>, callback: (payload: T) => void) {
|
||||
>genericFunction : <T>(object: GenericClass<T>, callback: (payload: T) => void) => void
|
||||
>T : T
|
||||
>object : GenericClass<T>
|
||||
>GenericClass : GenericClass<T>
|
||||
>T : T
|
||||
>callback : (payload: T) => void
|
||||
>payload : T
|
||||
>T : T
|
||||
|
||||
callback(object.payload);
|
||||
>callback(object.payload) : void
|
||||
>callback : (payload: T) => void
|
||||
>object.payload : T
|
||||
>object : GenericClass<T>
|
||||
>payload : T
|
||||
}
|
||||
|
||||
genericFunction(genericObject, ({greeting}) => {
|
||||
>genericFunction(genericObject, ({greeting}) => { var s = greeting.toLocaleLowerCase(); // Greeting should be of type string}) : void
|
||||
>genericFunction : <T>(object: GenericClass<T>, callback: (payload: T) => void) => void
|
||||
>genericObject : GenericClass<{ greeting: string; }>
|
||||
>({greeting}) => { var s = greeting.toLocaleLowerCase(); // Greeting should be of type string} : ({greeting}: { greeting: string; }) => void
|
||||
>greeting : string
|
||||
|
||||
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
|
||||
>s : string
|
||||
>greeting.toLocaleLowerCase() : string
|
||||
>greeting.toLocaleLowerCase : () => string
|
||||
>greeting : string
|
||||
>toLocaleLowerCase : () => string
|
||||
|
||||
});
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
tests/cases/conformance/enums/enumConstantMembers.ts(12,5): error TS1061: Enum member must have initializer.
|
||||
tests/cases/conformance/enums/enumConstantMembers.ts(18,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/enums/enumConstantMembers.ts (2 errors) ====
|
||||
// Constant members allow negatives, but not decimals. Also hex literals are allowed
|
||||
enum E1 {
|
||||
a = 1,
|
||||
b
|
||||
}
|
||||
enum E2 {
|
||||
a = - 1,
|
||||
b
|
||||
}
|
||||
enum E3 {
|
||||
a = 0.1,
|
||||
b // Error because 0.1 is not a constant
|
||||
~
|
||||
!!! error TS1061: Enum member must have initializer.
|
||||
}
|
||||
|
||||
declare enum E4 {
|
||||
a = 1,
|
||||
b = -1,
|
||||
c = 0.1 // Not a constant
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
=== tests/cases/conformance/enums/enumConstantMembers.ts ===
|
||||
// Constant members allow negatives, but not decimals. Also hex literals are allowed
|
||||
enum E1 {
|
||||
>E1 : Symbol(E1, Decl(enumConstantMembers.ts, 0, 0))
|
||||
|
||||
a = 1,
|
||||
>a : Symbol(E1.a, Decl(enumConstantMembers.ts, 1, 9))
|
||||
|
||||
b
|
||||
>b : Symbol(E1.b, Decl(enumConstantMembers.ts, 2, 10))
|
||||
}
|
||||
enum E2 {
|
||||
>E2 : Symbol(E2, Decl(enumConstantMembers.ts, 4, 1))
|
||||
|
||||
a = - 1,
|
||||
>a : Symbol(E2.a, Decl(enumConstantMembers.ts, 5, 9))
|
||||
|
||||
b
|
||||
>b : Symbol(E2.b, Decl(enumConstantMembers.ts, 6, 12))
|
||||
}
|
||||
enum E3 {
|
||||
>E3 : Symbol(E3, Decl(enumConstantMembers.ts, 8, 1))
|
||||
|
||||
a = 0.1,
|
||||
>a : Symbol(E3.a, Decl(enumConstantMembers.ts, 9, 9))
|
||||
|
||||
b // Error because 0.1 is not a constant
|
||||
>b : Symbol(E3.b, Decl(enumConstantMembers.ts, 10, 12))
|
||||
}
|
||||
|
||||
declare enum E4 {
|
||||
>E4 : Symbol(E4, Decl(enumConstantMembers.ts, 12, 1))
|
||||
|
||||
a = 1,
|
||||
>a : Symbol(E4.a, Decl(enumConstantMembers.ts, 14, 17))
|
||||
|
||||
b = -1,
|
||||
>b : Symbol(E4.b, Decl(enumConstantMembers.ts, 15, 10))
|
||||
|
||||
c = 0.1 // Not a constant
|
||||
>c : Symbol(E4.c, Decl(enumConstantMembers.ts, 16, 11))
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/conformance/enums/enumConstantMembers.ts ===
|
||||
// Constant members allow negatives, but not decimals. Also hex literals are allowed
|
||||
enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
a = 1,
|
||||
>a : E1
|
||||
>1 : number
|
||||
|
||||
b
|
||||
>b : E1
|
||||
}
|
||||
enum E2 {
|
||||
>E2 : E2
|
||||
|
||||
a = - 1,
|
||||
>a : E2
|
||||
>- 1 : number
|
||||
>1 : number
|
||||
|
||||
b
|
||||
>b : E2
|
||||
}
|
||||
enum E3 {
|
||||
>E3 : E3
|
||||
|
||||
a = 0.1,
|
||||
>a : E3
|
||||
>0.1 : number
|
||||
|
||||
b // Error because 0.1 is not a constant
|
||||
>b : E3
|
||||
}
|
||||
|
||||
declare enum E4 {
|
||||
>E4 : E4
|
||||
|
||||
a = 1,
|
||||
>a : E4
|
||||
>1 : number
|
||||
|
||||
b = -1,
|
||||
>b : E4
|
||||
>-1 : number
|
||||
>1 : number
|
||||
|
||||
c = 0.1 // Not a constant
|
||||
>c : E4
|
||||
>0.1 : number
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
tests/cases/compiler/enumInitializersWithExponents.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
tests/cases/compiler/enumInitializersWithExponents.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumInitializersWithExponents.ts (2 errors) ====
|
||||
// Must be integer literals.
|
||||
declare enum E {
|
||||
a = 1e3, // ok
|
||||
b = 1e25, // ok
|
||||
c = 1e-3, // error
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
d = 1e-9, // error
|
||||
~
|
||||
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||
e = 1e0, // ok
|
||||
f = 1e+25 // ok
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/compiler/enumInitializersWithExponents.ts ===
|
||||
// Must be integer literals.
|
||||
declare enum E {
|
||||
>E : Symbol(E, Decl(enumInitializersWithExponents.ts, 0, 0))
|
||||
|
||||
a = 1e3, // ok
|
||||
>a : Symbol(E.a, Decl(enumInitializersWithExponents.ts, 1, 16))
|
||||
|
||||
b = 1e25, // ok
|
||||
>b : Symbol(E.b, Decl(enumInitializersWithExponents.ts, 2, 12))
|
||||
|
||||
c = 1e-3, // error
|
||||
>c : Symbol(E.c, Decl(enumInitializersWithExponents.ts, 3, 13))
|
||||
|
||||
d = 1e-9, // error
|
||||
>d : Symbol(E.d, Decl(enumInitializersWithExponents.ts, 4, 13))
|
||||
|
||||
e = 1e0, // ok
|
||||
>e : Symbol(E.e, Decl(enumInitializersWithExponents.ts, 5, 13))
|
||||
|
||||
f = 1e+25 // ok
|
||||
>f : Symbol(E.f, Decl(enumInitializersWithExponents.ts, 6, 12))
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/enumInitializersWithExponents.ts ===
|
||||
// Must be integer literals.
|
||||
declare enum E {
|
||||
>E : E
|
||||
|
||||
a = 1e3, // ok
|
||||
>a : E
|
||||
>1e3 : number
|
||||
|
||||
b = 1e25, // ok
|
||||
>b : E
|
||||
>1e25 : number
|
||||
|
||||
c = 1e-3, // error
|
||||
>c : E
|
||||
>1e-3 : number
|
||||
|
||||
d = 1e-9, // error
|
||||
>d : E
|
||||
>1e-9 : number
|
||||
|
||||
e = 1e0, // ok
|
||||
>e : E
|
||||
>1e0 : number
|
||||
|
||||
f = 1e+25 // ok
|
||||
>f : E
|
||||
>1e+25 : number
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts(4,5): error TS1061: Enum member must have initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts (1 errors) ====
|
||||
enum E {
|
||||
a,
|
||||
b = a,
|
||||
c
|
||||
~
|
||||
!!! error TS1061: Enum member must have initializer.
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts ===
|
||||
enum E {
|
||||
>E : Symbol(E, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 0))
|
||||
|
||||
a,
|
||||
>a : Symbol(E.a, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 8))
|
||||
|
||||
b = a,
|
||||
>b : Symbol(E.b, Decl(enumWithoutInitializerAfterComputedMember.ts, 1, 6))
|
||||
>a : Symbol(E.a, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 8))
|
||||
|
||||
c
|
||||
>c : Symbol(E.c, Decl(enumWithoutInitializerAfterComputedMember.ts, 2, 10))
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts ===
|
||||
enum E {
|
||||
>E : E
|
||||
|
||||
a,
|
||||
>a : E
|
||||
|
||||
b = a,
|
||||
>b : E
|
||||
>a : E
|
||||
|
||||
c
|
||||
>c : E
|
||||
}
|
||||
@@ -15,14 +15,14 @@ export class A
|
||||
|
||||
|
||||
//// [es5-umd2.js]
|
||||
(function (deps, factory) {
|
||||
(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(deps, factory);
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(["require", "exports"], function (require, exports) {
|
||||
})(function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ export default class A
|
||||
|
||||
|
||||
//// [es5-umd3.js]
|
||||
(function (deps, factory) {
|
||||
(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(deps, factory);
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(["require", "exports"], function (require, exports) {
|
||||
})(function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ export = A;
|
||||
|
||||
|
||||
//// [es5-umd4.js]
|
||||
(function (deps, factory) {
|
||||
(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(deps, factory);
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(["require", "exports"], function (require, exports) {
|
||||
})(function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower.
|
||||
==== tests/cases/compiler/es5andes6module.ts (0 errors) ====
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [es5andes6module.ts]
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [es5andes6module.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.default = A;
|
||||
@@ -1,18 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : Symbol(A, Decl(es6-amd.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6-amd.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6-declaration-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : Symbol(A, Decl(es6-declaration-amd.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6-declaration-amd.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6-declaration-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6-sourcemap-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : Symbol(A, Decl(es6-sourcemap-amd.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6-sourcemap-amd.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6-sourcemap-amd.ts ===
|
||||
|
||||
class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6-umd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6-umd.ts ===
|
||||
|
||||
class A
|
||||
>A : Symbol(A, Decl(es6-umd.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6-umd.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6-umd.ts ===
|
||||
|
||||
class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6-umd2.ts (0 errors) ====
|
||||
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,20 @@ export class A
|
||||
}
|
||||
|
||||
//// [es6-umd2.js]
|
||||
export class A {
|
||||
constructor() {
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
}
|
||||
})(function (require, exports) {
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
exports.A = A;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6-umd2.ts ===
|
||||
|
||||
export class A
|
||||
>A : Symbol(A, Decl(es6-umd2.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6-umd2.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6-umd2.ts ===
|
||||
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ====
|
||||
@@ -6,4 +6,4 @@ tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignmen
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
@@ -6,7 +6,7 @@ tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used w
|
||||
var a = 10;
|
||||
export = a; // Error: export = not allowed in ES6
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
import * as a from "a";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment
|
||||
|
||||
export = f;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ====
|
||||
|
||||
export var a = 10;
|
||||
export var x = a;
|
||||
export var m = a;
|
||||
export default {};
|
||||
|
||||
==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (0 errors) ====
|
||||
import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1: number = a;
|
||||
import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1: number = b;
|
||||
import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1: number = x;
|
||||
var x1: number = y;
|
||||
import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1: number = z;
|
||||
import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1: number = m;
|
||||
|
||||
@@ -23,22 +23,22 @@ var x1: number = m;
|
||||
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_0.js]
|
||||
export var a = 10;
|
||||
export var x = a;
|
||||
export var m = a;
|
||||
export default {};
|
||||
exports.a = 10;
|
||||
exports.x = exports.a;
|
||||
exports.m = exports.a;
|
||||
exports.default = {};
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_1.js]
|
||||
import { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1 = a;
|
||||
import { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1 = b;
|
||||
import { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1 = x;
|
||||
var x1 = y;
|
||||
import { x as z } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1 = z;
|
||||
import { m } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
var x1 = m;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_1.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_2.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.x;
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.a;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_4.x;
|
||||
var es6ImportDefaultBindingFollowedWithNamedImport_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0");
|
||||
var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_5.m;
|
||||
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts]
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10))
|
||||
|
||||
export var x = a;
|
||||
>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10))
|
||||
|
||||
export var m = a;
|
||||
>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 3, 10))
|
||||
>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10))
|
||||
|
||||
export default {};
|
||||
|
||||
=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts ===
|
||||
import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding1 : Symbol(defaultBinding1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 0, 6))
|
||||
|
||||
import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 6))
|
||||
>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25))
|
||||
|
||||
var x1: number = a;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25))
|
||||
|
||||
import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding3 : Symbol(defaultBinding3, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 6))
|
||||
>a : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25))
|
||||
>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25))
|
||||
|
||||
var x1: number = b;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25))
|
||||
|
||||
import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding4 : Symbol(defaultBinding4, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 6))
|
||||
>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25))
|
||||
>a : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28))
|
||||
>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28))
|
||||
|
||||
var x1: number = x;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25))
|
||||
|
||||
var x1: number = y;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28))
|
||||
|
||||
import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding5 : Symbol(defaultBinding5, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 6))
|
||||
>x : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25))
|
||||
>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25))
|
||||
|
||||
var x1: number = z;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25))
|
||||
|
||||
import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding6 : Symbol(defaultBinding6, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 6))
|
||||
>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25))
|
||||
|
||||
var x1: number = m;
|
||||
>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3))
|
||||
>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25))
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
export var x = a;
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
export var m = a;
|
||||
>m : number
|
||||
>a : number
|
||||
|
||||
export default {};
|
||||
>{} : {}
|
||||
|
||||
=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts ===
|
||||
import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding1 : {}
|
||||
|
||||
import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding2 : {}
|
||||
>a : number
|
||||
|
||||
var x1: number = a;
|
||||
>x1 : number
|
||||
>a : number
|
||||
|
||||
import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding3 : {}
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
var x1: number = b;
|
||||
>x1 : number
|
||||
>b : number
|
||||
|
||||
import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding4 : {}
|
||||
>x : number
|
||||
>a : number
|
||||
>y : number
|
||||
|
||||
var x1: number = x;
|
||||
>x1 : number
|
||||
>x : number
|
||||
|
||||
var x1: number = y;
|
||||
>x1 : number
|
||||
>y : number
|
||||
|
||||
import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding5 : {}
|
||||
>x : number
|
||||
>z : number
|
||||
|
||||
var x1: number = z;
|
||||
>x1 : number
|
||||
>z : number
|
||||
|
||||
import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
>defaultBinding6 : {}
|
||||
>m : number
|
||||
|
||||
var x1: number = m;
|
||||
>x1 : number
|
||||
>m : number
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/client.ts (1 errors) ====
|
||||
import a = require("server");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
|
||||
==== tests/cases/compiler/server.ts (1 errors) ====
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ====
|
||||
|
||||
export var a = 10;
|
||||
|
||||
==== tests/cases/compiler/es6ImportNameSpaceImport_1.ts (0 errors) ====
|
||||
import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0";
|
||||
var x = nameSpaceBinding.a;
|
||||
import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this
|
||||
|
||||
@@ -11,9 +11,9 @@ import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this
|
||||
|
||||
|
||||
//// [es6ImportNameSpaceImport_0.js]
|
||||
export var a = 10;
|
||||
exports.a = 10;
|
||||
//// [es6ImportNameSpaceImport_1.js]
|
||||
import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0";
|
||||
var nameSpaceBinding = require("./es6ImportNameSpaceImport_0");
|
||||
var x = nameSpaceBinding.a;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : Symbol(a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts ===
|
||||
import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0";
|
||||
>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6))
|
||||
|
||||
var x = nameSpaceBinding.a;
|
||||
>x : Symbol(x, Decl(es6ImportNameSpaceImport_1.ts, 1, 3))
|
||||
>nameSpaceBinding.a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10))
|
||||
>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6))
|
||||
>a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10))
|
||||
|
||||
import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this
|
||||
>nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(es6ImportNameSpaceImport_1.ts, 2, 6))
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts ===
|
||||
import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0";
|
||||
>nameSpaceBinding : typeof nameSpaceBinding
|
||||
|
||||
var x = nameSpaceBinding.a;
|
||||
>x : number
|
||||
>nameSpaceBinding.a : number
|
||||
>nameSpaceBinding : typeof nameSpaceBinding
|
||||
>a : number
|
||||
|
||||
import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this
|
||||
>nameSpaceBinding2 : typeof nameSpaceBinding
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ====
|
||||
|
||||
export var a = 10;
|
||||
export var x = a;
|
||||
export var m = a;
|
||||
export var a1 = 10;
|
||||
export var x1 = 10;
|
||||
export var z1 = 10;
|
||||
export var z2 = 10;
|
||||
export var aaaa = 10;
|
||||
|
||||
==== tests/cases/compiler/es6ImportNamedImport_1.ts (0 errors) ====
|
||||
import { } from "./es6ImportNamedImport_0";
|
||||
import { a } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a;
|
||||
import { a as b } from "./es6ImportNamedImport_0";
|
||||
var xxxx = b;
|
||||
import { x, a as y } from "./es6ImportNamedImport_0";
|
||||
var xxxx = x;
|
||||
var xxxx = y;
|
||||
import { x as z, } from "./es6ImportNamedImport_0";
|
||||
var xxxx = z;
|
||||
import { m, } from "./es6ImportNamedImport_0";
|
||||
var xxxx = m;
|
||||
import { a1, x1 } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a1;
|
||||
var xxxx = x1;
|
||||
import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a11;
|
||||
var xxxx = x11;
|
||||
import { z1 } from "./es6ImportNamedImport_0";
|
||||
var z111 = z1;
|
||||
import { z2 as z3 } from "./es6ImportNamedImport_0";
|
||||
var z2 = z3; // z2 shouldn't give redeclare error
|
||||
|
||||
// These are elided
|
||||
import { aaaa } from "./es6ImportNamedImport_0";
|
||||
// These are elided
|
||||
import { aaaa as bbbb } from "./es6ImportNamedImport_0";
|
||||
|
||||
@@ -42,36 +42,36 @@ import { aaaa as bbbb } from "./es6ImportNamedImport_0";
|
||||
|
||||
|
||||
//// [es6ImportNamedImport_0.js]
|
||||
export var a = 10;
|
||||
export var x = a;
|
||||
export var m = a;
|
||||
export var a1 = 10;
|
||||
export var x1 = 10;
|
||||
export var z1 = 10;
|
||||
export var z2 = 10;
|
||||
export var aaaa = 10;
|
||||
exports.a = 10;
|
||||
exports.x = exports.a;
|
||||
exports.m = exports.a;
|
||||
exports.a1 = 10;
|
||||
exports.x1 = 10;
|
||||
exports.z1 = 10;
|
||||
exports.z2 = 10;
|
||||
exports.aaaa = 10;
|
||||
//// [es6ImportNamedImport_1.js]
|
||||
import { a } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a;
|
||||
import { a as b } from "./es6ImportNamedImport_0";
|
||||
var xxxx = b;
|
||||
import { x, a as y } from "./es6ImportNamedImport_0";
|
||||
var xxxx = x;
|
||||
var xxxx = y;
|
||||
import { x as z } from "./es6ImportNamedImport_0";
|
||||
var xxxx = z;
|
||||
import { m } from "./es6ImportNamedImport_0";
|
||||
var xxxx = m;
|
||||
import { a1, x1 } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a1;
|
||||
var xxxx = x1;
|
||||
import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0";
|
||||
var xxxx = a11;
|
||||
var xxxx = x11;
|
||||
import { z1 } from "./es6ImportNamedImport_0";
|
||||
var z111 = z1;
|
||||
import { z2 as z3 } from "./es6ImportNamedImport_0";
|
||||
var z2 = z3; // z2 shouldn't give redeclare error
|
||||
var es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_1.a;
|
||||
var es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_2.a;
|
||||
var es6ImportNamedImport_0_3 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_3.x;
|
||||
var xxxx = es6ImportNamedImport_0_3.a;
|
||||
var es6ImportNamedImport_0_4 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_4.x;
|
||||
var es6ImportNamedImport_0_5 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_5.m;
|
||||
var es6ImportNamedImport_0_6 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_6.a1;
|
||||
var xxxx = es6ImportNamedImport_0_6.x1;
|
||||
var es6ImportNamedImport_0_7 = require("./es6ImportNamedImport_0");
|
||||
var xxxx = es6ImportNamedImport_0_7.a1;
|
||||
var xxxx = es6ImportNamedImport_0_7.x1;
|
||||
var es6ImportNamedImport_0_8 = require("./es6ImportNamedImport_0");
|
||||
var z111 = es6ImportNamedImport_0_8.z1;
|
||||
var es6ImportNamedImport_0_9 = require("./es6ImportNamedImport_0");
|
||||
var z2 = es6ImportNamedImport_0_9.z2; // z2 shouldn't give redeclare error
|
||||
|
||||
|
||||
//// [es6ImportNamedImport_0.d.ts]
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
=== tests/cases/compiler/es6ImportNamedImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10))
|
||||
|
||||
export var x = a;
|
||||
>x : Symbol(x, Decl(es6ImportNamedImport_0.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10))
|
||||
|
||||
export var m = a;
|
||||
>m : Symbol(m, Decl(es6ImportNamedImport_0.ts, 3, 10))
|
||||
>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10))
|
||||
|
||||
export var a1 = 10;
|
||||
>a1 : Symbol(a1, Decl(es6ImportNamedImport_0.ts, 4, 10))
|
||||
|
||||
export var x1 = 10;
|
||||
>x1 : Symbol(x1, Decl(es6ImportNamedImport_0.ts, 5, 10))
|
||||
|
||||
export var z1 = 10;
|
||||
>z1 : Symbol(z1, Decl(es6ImportNamedImport_0.ts, 6, 10))
|
||||
|
||||
export var z2 = 10;
|
||||
>z2 : Symbol(z2, Decl(es6ImportNamedImport_0.ts, 7, 10))
|
||||
|
||||
export var aaaa = 10;
|
||||
>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_0.ts, 8, 10))
|
||||
|
||||
=== tests/cases/compiler/es6ImportNamedImport_1.ts ===
|
||||
import { } from "./es6ImportNamedImport_0";
|
||||
import { a } from "./es6ImportNamedImport_0";
|
||||
>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8))
|
||||
|
||||
var xxxx = a;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8))
|
||||
|
||||
import { a as b } from "./es6ImportNamedImport_0";
|
||||
>a : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8))
|
||||
>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8))
|
||||
|
||||
var xxxx = b;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8))
|
||||
|
||||
import { x, a as y } from "./es6ImportNamedImport_0";
|
||||
>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8))
|
||||
>a : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11))
|
||||
>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11))
|
||||
|
||||
var xxxx = x;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8))
|
||||
|
||||
var xxxx = y;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11))
|
||||
|
||||
import { x as z, } from "./es6ImportNamedImport_0";
|
||||
>x : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8))
|
||||
>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8))
|
||||
|
||||
var xxxx = z;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8))
|
||||
|
||||
import { m, } from "./es6ImportNamedImport_0";
|
||||
>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8))
|
||||
|
||||
var xxxx = m;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8))
|
||||
|
||||
import { a1, x1 } from "./es6ImportNamedImport_0";
|
||||
>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8))
|
||||
>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12))
|
||||
|
||||
var xxxx = a1;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8))
|
||||
|
||||
var xxxx = x1;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12))
|
||||
|
||||
import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0";
|
||||
>a1 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8))
|
||||
>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8))
|
||||
>x1 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19))
|
||||
>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19))
|
||||
|
||||
var xxxx = a11;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8))
|
||||
|
||||
var xxxx = x11;
|
||||
>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3))
|
||||
>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19))
|
||||
|
||||
import { z1 } from "./es6ImportNamedImport_0";
|
||||
>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8))
|
||||
|
||||
var z111 = z1;
|
||||
>z111 : Symbol(z111, Decl(es6ImportNamedImport_1.ts, 19, 3))
|
||||
>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8))
|
||||
|
||||
import { z2 as z3 } from "./es6ImportNamedImport_0";
|
||||
>z2 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8))
|
||||
>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8))
|
||||
|
||||
var z2 = z3; // z2 shouldn't give redeclare error
|
||||
>z2 : Symbol(z2, Decl(es6ImportNamedImport_1.ts, 21, 3))
|
||||
>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8))
|
||||
|
||||
// These are elided
|
||||
import { aaaa } from "./es6ImportNamedImport_0";
|
||||
>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_1.ts, 24, 8))
|
||||
|
||||
// These are elided
|
||||
import { aaaa as bbbb } from "./es6ImportNamedImport_0";
|
||||
>aaaa : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8))
|
||||
>bbbb : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8))
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
=== tests/cases/compiler/es6ImportNamedImport_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
export var x = a;
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
export var m = a;
|
||||
>m : number
|
||||
>a : number
|
||||
|
||||
export var a1 = 10;
|
||||
>a1 : number
|
||||
>10 : number
|
||||
|
||||
export var x1 = 10;
|
||||
>x1 : number
|
||||
>10 : number
|
||||
|
||||
export var z1 = 10;
|
||||
>z1 : number
|
||||
>10 : number
|
||||
|
||||
export var z2 = 10;
|
||||
>z2 : number
|
||||
>10 : number
|
||||
|
||||
export var aaaa = 10;
|
||||
>aaaa : number
|
||||
>10 : number
|
||||
|
||||
=== tests/cases/compiler/es6ImportNamedImport_1.ts ===
|
||||
import { } from "./es6ImportNamedImport_0";
|
||||
import { a } from "./es6ImportNamedImport_0";
|
||||
>a : number
|
||||
|
||||
var xxxx = a;
|
||||
>xxxx : number
|
||||
>a : number
|
||||
|
||||
import { a as b } from "./es6ImportNamedImport_0";
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
var xxxx = b;
|
||||
>xxxx : number
|
||||
>b : number
|
||||
|
||||
import { x, a as y } from "./es6ImportNamedImport_0";
|
||||
>x : number
|
||||
>a : number
|
||||
>y : number
|
||||
|
||||
var xxxx = x;
|
||||
>xxxx : number
|
||||
>x : number
|
||||
|
||||
var xxxx = y;
|
||||
>xxxx : number
|
||||
>y : number
|
||||
|
||||
import { x as z, } from "./es6ImportNamedImport_0";
|
||||
>x : number
|
||||
>z : number
|
||||
|
||||
var xxxx = z;
|
||||
>xxxx : number
|
||||
>z : number
|
||||
|
||||
import { m, } from "./es6ImportNamedImport_0";
|
||||
>m : number
|
||||
|
||||
var xxxx = m;
|
||||
>xxxx : number
|
||||
>m : number
|
||||
|
||||
import { a1, x1 } from "./es6ImportNamedImport_0";
|
||||
>a1 : number
|
||||
>x1 : number
|
||||
|
||||
var xxxx = a1;
|
||||
>xxxx : number
|
||||
>a1 : number
|
||||
|
||||
var xxxx = x1;
|
||||
>xxxx : number
|
||||
>x1 : number
|
||||
|
||||
import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0";
|
||||
>a1 : number
|
||||
>a11 : number
|
||||
>x1 : number
|
||||
>x11 : number
|
||||
|
||||
var xxxx = a11;
|
||||
>xxxx : number
|
||||
>a11 : number
|
||||
|
||||
var xxxx = x11;
|
||||
>xxxx : number
|
||||
>x11 : number
|
||||
|
||||
import { z1 } from "./es6ImportNamedImport_0";
|
||||
>z1 : number
|
||||
|
||||
var z111 = z1;
|
||||
>z111 : number
|
||||
>z1 : number
|
||||
|
||||
import { z2 as z3 } from "./es6ImportNamedImport_0";
|
||||
>z2 : number
|
||||
>z3 : number
|
||||
|
||||
var z2 = z3; // z2 shouldn't give redeclare error
|
||||
>z2 : number
|
||||
>z3 : number
|
||||
|
||||
// These are elided
|
||||
import { aaaa } from "./es6ImportNamedImport_0";
|
||||
>aaaa : number
|
||||
|
||||
// These are elided
|
||||
import { aaaa as bbbb } from "./es6ImportNamedImport_0";
|
||||
>aaaa : number
|
||||
>bbbb : number
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ====
|
||||
|
||||
export var a = 10;
|
||||
|
||||
==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts (1 errors) ====
|
||||
import { a } from "./es6ImportNamedImportInExportAssignment_0";
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
@@ -9,9 +9,10 @@ import { a } from "./es6ImportNamedImportInExportAssignment_0";
|
||||
export = a;
|
||||
|
||||
//// [es6ImportNamedImportInExportAssignment_0.js]
|
||||
export var a = 10;
|
||||
exports.a = 10;
|
||||
//// [es6ImportNamedImportInExportAssignment_1.js]
|
||||
import { a } from "./es6ImportNamedImportInExportAssignment_0";
|
||||
var es6ImportNamedImportInExportAssignment_0_1 = require("./es6ImportNamedImportInExportAssignment_0");
|
||||
module.exports = es6ImportNamedImportInExportAssignment_0_1.a;
|
||||
|
||||
|
||||
//// [es6ImportNamedImportInExportAssignment_0.d.ts]
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_0.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts ===
|
||||
import { a } from "./es6ImportNamedImportInExportAssignment_0";
|
||||
>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8))
|
||||
|
||||
export = a;
|
||||
>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts ===
|
||||
|
||||
export var a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts ===
|
||||
import { a } from "./es6ImportNamedImportInExportAssignment_0";
|
||||
>a : number
|
||||
|
||||
export = a;
|
||||
>a : number
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ====
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,13 @@ export class A
|
||||
}
|
||||
|
||||
//// [es6ModuleWithModuleGenTargetAmd.js]
|
||||
export class A {
|
||||
constructor() {
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
exports.A = A;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts ===
|
||||
export class A
|
||||
>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetAmd.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetAmd.ts, 4, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts ===
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.
|
||||
==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ====
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,11 @@ export class A
|
||||
}
|
||||
|
||||
//// [es6ModuleWithModuleGenTargetCommonjs.js]
|
||||
export class A {
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
exports.A = A;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts ===
|
||||
export class A
|
||||
>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 4, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts ===
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [es6modulekind.ts]
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6modulekind.js]
|
||||
export default class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6modulekind.ts ===
|
||||
|
||||
export default class A
|
||||
>A : Symbol(A, Decl(es6modulekind.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6modulekind.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6modulekind.ts ===
|
||||
|
||||
export default class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -35,14 +35,14 @@ export let h1: D = new D;
|
||||
|
||||
|
||||
//// [exportNonInitializedVariablesUMD.js]
|
||||
(function (deps, factory) {
|
||||
(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(deps, factory);
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(["require", "exports"], function (require, exports) {
|
||||
})(function (require, exports) {
|
||||
var ;
|
||||
let;
|
||||
var ;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [implementsInClassExpression.ts]
|
||||
interface Foo {
|
||||
doThing(): void;
|
||||
}
|
||||
|
||||
let cls = class implements Foo {
|
||||
doThing() { }
|
||||
}
|
||||
|
||||
//// [implementsInClassExpression.js]
|
||||
var cls = (function () {
|
||||
function class_1() {
|
||||
}
|
||||
class_1.prototype.doThing = function () { };
|
||||
return class_1;
|
||||
})();
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/implementsInClassExpression.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0))
|
||||
|
||||
doThing(): void;
|
||||
>doThing : Symbol(doThing, Decl(implementsInClassExpression.ts, 0, 15))
|
||||
}
|
||||
|
||||
let cls = class implements Foo {
|
||||
>cls : Symbol(cls, Decl(implementsInClassExpression.ts, 4, 3))
|
||||
>Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0))
|
||||
|
||||
doThing() { }
|
||||
>doThing : Symbol((Anonymous class).doThing, Decl(implementsInClassExpression.ts, 4, 32))
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/implementsInClassExpression.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
doThing(): void;
|
||||
>doThing : () => void
|
||||
}
|
||||
|
||||
let cls = class implements Foo {
|
||||
>cls : typeof (Anonymous class)
|
||||
>class implements Foo { doThing() { }} : typeof (Anonymous class)
|
||||
>Foo : Foo
|
||||
|
||||
doThing() { }
|
||||
>doThing : () => void
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user