mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'refs/remotes/Microsoft/master' into formatWhitespaces
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '4'
|
||||
- '0.10'
|
||||
|
||||
|
||||
+18
-3
@@ -8,6 +8,7 @@ TypeScript is authored by:
|
||||
* Basarat Ali Syed
|
||||
* Ben Duffield
|
||||
* Bill Ticehurst
|
||||
* Brett Mayen
|
||||
* Bryan Forbes
|
||||
* Caitlin Potter
|
||||
* Chris Bubernak
|
||||
@@ -17,11 +18,14 @@ TypeScript is authored by:
|
||||
* Dan Quirk
|
||||
* Daniel Rosenwasser
|
||||
* David Li
|
||||
* Dick van den Brink
|
||||
* Dirk Bäumer
|
||||
* Denis Nedelyaev
|
||||
* Dick van den Brink
|
||||
* Dirk Bäumer
|
||||
* Eyas Sharaiha
|
||||
* Frank Wallis
|
||||
* Gabriel Isenberg
|
||||
* Gilad Peleg
|
||||
* Graeme Wicksted
|
||||
* Guillaume Salles
|
||||
* Harald Niesche
|
||||
* Ingvar Stepanyan
|
||||
@@ -31,30 +35,39 @@ TypeScript is authored by:
|
||||
* Jason Ramsay
|
||||
* Jed Mao
|
||||
* Johannes Rieken
|
||||
* John Vilk
|
||||
* Jonathan Bond-Caron
|
||||
* Jonathan Park
|
||||
* Jonathan Turner
|
||||
* Josh Kalderimis
|
||||
* Julian Williams
|
||||
* Kagami Sascha Rosylight
|
||||
* Keith Mashinter
|
||||
* Ken Howard
|
||||
* Kenji Imamula
|
||||
* Lorant Pinter
|
||||
* Martin Všetička
|
||||
* Masahiro Wakame
|
||||
* Max Deepfield
|
||||
* Micah Zoltu
|
||||
* Mohamed Hegazy
|
||||
* Nathan Shively-Sanders
|
||||
* Oleg Mihailik
|
||||
* Oleksandr Chekhovskyi
|
||||
* Paul van Brenk
|
||||
* Pedro Maltez
|
||||
* Philip Bulley
|
||||
* piloopin
|
||||
* @progre
|
||||
* Punya Biswal
|
||||
* Ron Buckton
|
||||
* Ryan Cavanaugh
|
||||
* Ryohei Ikegami
|
||||
* Sébastien Arod
|
||||
* Sheetal Nandi
|
||||
* Shengping Zhong
|
||||
* Shyyko Serhiy
|
||||
* Simon Hürlimann
|
||||
* Simon H�rlimann
|
||||
* Solal Pirelli
|
||||
* Stan Thomas
|
||||
* Steve Lucco
|
||||
@@ -63,8 +76,10 @@ TypeScript is authored by:
|
||||
* togru
|
||||
* Tomas Grubliauskas
|
||||
* TruongSinh Tran-Nguyen
|
||||
* Viliv Vane
|
||||
* Vladimir Matveev
|
||||
* Wesley Wigham
|
||||
* York Yao
|
||||
* Yui Tanglertsampan
|
||||
* Zev Spitz
|
||||
* Zhengbo Li
|
||||
+4
-1
@@ -228,7 +228,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
|
||||
file(outFile, prereqs, function() {
|
||||
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
|
||||
var options = "--module commonjs --noImplicitAny --noEmitOnError --pretty";
|
||||
var options = "--noImplicitAny --noEmitOnError --pretty";
|
||||
|
||||
// Keep comments when specifically requested
|
||||
// or when in debug mode.
|
||||
@@ -251,6 +251,9 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
|
||||
if (!noOutFile) {
|
||||
options += " --out " + outFile;
|
||||
}
|
||||
else {
|
||||
options += " --module commonjs"
|
||||
}
|
||||
|
||||
if(noResolve) {
|
||||
options += " --noResolve";
|
||||
|
||||
+1859
-1423
File diff suppressed because it is too large
Load Diff
+1057
-557
File diff suppressed because it is too large
Load Diff
Vendored
+13
-6
@@ -387,6 +387,7 @@ declare namespace ts {
|
||||
right: Identifier;
|
||||
}
|
||||
type EntityName = Identifier | QualifiedName;
|
||||
type PropertyName = Identifier | LiteralExpression | ComputedPropertyName;
|
||||
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
|
||||
interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
@@ -425,7 +426,7 @@ declare namespace ts {
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: Node;
|
||||
name: Identifier | BindingPattern;
|
||||
initializer?: Expression;
|
||||
@@ -452,7 +453,7 @@ declare namespace ts {
|
||||
objectAssignmentInitializer?: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: Node;
|
||||
name: DeclarationName;
|
||||
questionToken?: Node;
|
||||
@@ -581,7 +582,7 @@ declare namespace ts {
|
||||
asteriskToken?: Node;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
interface BinaryExpression extends Expression, Declaration {
|
||||
left: Expression;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
@@ -625,7 +626,7 @@ declare namespace ts {
|
||||
interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
}
|
||||
interface PropertyAccessExpression extends MemberExpression {
|
||||
interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
@@ -1220,6 +1221,7 @@ declare namespace ts {
|
||||
ObjectLiteral = 524288,
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
@@ -1537,7 +1539,6 @@ declare namespace ts {
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@@ -2126,6 +2127,9 @@ declare namespace ts {
|
||||
static typeAliasName: string;
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
static jsxOpenTagName: string;
|
||||
static jsxCloseTagName: string;
|
||||
static jsxSelfClosingTagName: string;
|
||||
}
|
||||
enum ClassificationType {
|
||||
comment = 1,
|
||||
@@ -2146,6 +2150,9 @@ declare namespace ts {
|
||||
typeAliasName = 16,
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
jsxOpenTagName = 19,
|
||||
jsxCloseTagName = 20,
|
||||
jsxSelfClosingTagName = 21,
|
||||
}
|
||||
interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
@@ -2171,7 +2178,7 @@ declare namespace ts {
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
/**
|
||||
|
||||
+2546
-1958
File diff suppressed because it is too large
Load Diff
Vendored
+13
-6
@@ -387,6 +387,7 @@ declare namespace ts {
|
||||
right: Identifier;
|
||||
}
|
||||
type EntityName = Identifier | QualifiedName;
|
||||
type PropertyName = Identifier | LiteralExpression | ComputedPropertyName;
|
||||
type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
|
||||
interface Declaration extends Node {
|
||||
_declarationBrand: any;
|
||||
@@ -425,7 +426,7 @@ declare namespace ts {
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface BindingElement extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: Node;
|
||||
name: Identifier | BindingPattern;
|
||||
initializer?: Expression;
|
||||
@@ -452,7 +453,7 @@ declare namespace ts {
|
||||
objectAssignmentInitializer?: Expression;
|
||||
}
|
||||
interface VariableLikeDeclaration extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: Node;
|
||||
name: DeclarationName;
|
||||
questionToken?: Node;
|
||||
@@ -581,7 +582,7 @@ declare namespace ts {
|
||||
asteriskToken?: Node;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
interface BinaryExpression extends Expression, Declaration {
|
||||
left: Expression;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
@@ -625,7 +626,7 @@ declare namespace ts {
|
||||
interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
}
|
||||
interface PropertyAccessExpression extends MemberExpression {
|
||||
interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
@@ -1220,6 +1221,7 @@ declare namespace ts {
|
||||
ObjectLiteral = 524288,
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
@@ -1537,7 +1539,6 @@ declare namespace ts {
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
}
|
||||
declare namespace ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
@@ -2126,6 +2127,9 @@ declare namespace ts {
|
||||
static typeAliasName: string;
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
static jsxOpenTagName: string;
|
||||
static jsxCloseTagName: string;
|
||||
static jsxSelfClosingTagName: string;
|
||||
}
|
||||
enum ClassificationType {
|
||||
comment = 1,
|
||||
@@ -2146,6 +2150,9 @@ declare namespace ts {
|
||||
typeAliasName = 16,
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
jsxOpenTagName = 19,
|
||||
jsxCloseTagName = 20,
|
||||
jsxSelfClosingTagName = 21,
|
||||
}
|
||||
interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
@@ -2171,7 +2178,7 @@ declare namespace ts {
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
/**
|
||||
|
||||
+2546
-1958
File diff suppressed because it is too large
Load Diff
+67
-6
@@ -1,3 +1,4 @@
|
||||
/// <reference path="utilities.ts"/>
|
||||
/// <reference path="parser.ts"/>
|
||||
|
||||
/* @internal */
|
||||
@@ -6,8 +7,8 @@ namespace ts {
|
||||
|
||||
export const enum ModuleInstanceState {
|
||||
NonInstantiated = 0,
|
||||
Instantiated = 1,
|
||||
ConstEnumOnly = 2
|
||||
Instantiated = 1,
|
||||
ConstEnumOnly = 2
|
||||
}
|
||||
|
||||
const enum Reachability {
|
||||
@@ -188,6 +189,11 @@ namespace ts {
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
if (isStringOrNumericLiteral(nameExpression.kind)) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
|
||||
}
|
||||
@@ -208,6 +214,9 @@ namespace ts {
|
||||
return "__export";
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (<ExportAssignment>node).isExportEquals ? "export=" : "default";
|
||||
case SyntaxKind.BinaryExpression:
|
||||
// Binary expression case is for JS module 'module.exports = expr'
|
||||
return "export=";
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return node.flags & NodeFlags.Default ? "default" : undefined;
|
||||
@@ -1069,7 +1078,7 @@ namespace ts {
|
||||
return "__" + indexOf((<SignatureDeclaration>node.parent).parameters, node);
|
||||
}
|
||||
|
||||
function bind(node: Node) {
|
||||
function bind(node: Node): void {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
@@ -1145,9 +1154,18 @@ namespace ts {
|
||||
|
||||
function bindWorker(node: Node) {
|
||||
switch (node.kind) {
|
||||
/* Strict mode checks */
|
||||
case SyntaxKind.Identifier:
|
||||
return checkStrictModeIdentifier(<Identifier>node);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if (isInJavaScriptFile(node)) {
|
||||
if (isExportsPropertyAssignment(node)) {
|
||||
bindExportsPropertyAssignment(<BinaryExpression>node);
|
||||
}
|
||||
else if (isModuleExportsAssignment(node)) {
|
||||
bindModuleExportsAssignment(<BinaryExpression>node);
|
||||
}
|
||||
}
|
||||
return checkStrictModeBinaryExpression(<BinaryExpression>node);
|
||||
case SyntaxKind.CatchClause:
|
||||
return checkStrictModeCatchClause(<CatchClause>node);
|
||||
@@ -1213,6 +1231,14 @@ namespace ts {
|
||||
checkStrictModeFunctionName(<FunctionExpression>node);
|
||||
const bindingName = (<FunctionExpression>node).name ? (<FunctionExpression>node).name.text : "__function";
|
||||
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, bindingName);
|
||||
|
||||
case SyntaxKind.CallExpression:
|
||||
if (isInJavaScriptFile(node)) {
|
||||
bindCallExpression(<CallExpression>node);
|
||||
}
|
||||
break;
|
||||
|
||||
// Members of classes, interfaces, and modules
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
|
||||
@@ -1224,6 +1250,8 @@ namespace ts {
|
||||
return bindEnumDeclaration(<EnumDeclaration>node);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return bindModuleDeclaration(<ModuleDeclaration>node);
|
||||
|
||||
// Imports and exports
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
@@ -1243,16 +1271,21 @@ namespace ts {
|
||||
function bindSourceFileIfExternalModule() {
|
||||
setExportContextFlag(file);
|
||||
if (isExternalModule(file)) {
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`);
|
||||
bindSourceFileAsExternalModule();
|
||||
}
|
||||
}
|
||||
|
||||
function bindExportAssignment(node: ExportAssignment) {
|
||||
function bindSourceFileAsExternalModule() {
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
|
||||
}
|
||||
|
||||
function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
|
||||
const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (<ExportAssignment>node).expression : (<BinaryExpression>node).right;
|
||||
if (!container.symbol || !container.symbol.exports) {
|
||||
// Export assignment in some sort of block construct
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
|
||||
}
|
||||
else if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
else if (boundExpression.kind === SyntaxKind.Identifier) {
|
||||
// An export default clause with an identifier exports all meanings of that identifier
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
}
|
||||
@@ -1279,6 +1312,34 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function setCommonJsModuleIndicator(node: Node) {
|
||||
if (!file.commonJsModuleIndicator) {
|
||||
file.commonJsModuleIndicator = node;
|
||||
bindSourceFileAsExternalModule();
|
||||
}
|
||||
}
|
||||
|
||||
function bindExportsPropertyAssignment(node: BinaryExpression) {
|
||||
// When we create a property via 'exports.foo = bar', the 'exports.foo' property access
|
||||
// expression is the declaration
|
||||
setCommonJsModuleIndicator(node);
|
||||
declareSymbol(file.symbol.exports, file.symbol, <PropertyAccessExpression>node.left, SymbolFlags.Property | SymbolFlags.Export, SymbolFlags.None);
|
||||
}
|
||||
|
||||
function bindModuleExportsAssignment(node: BinaryExpression) {
|
||||
// 'module.exports = expr' assignment
|
||||
setCommonJsModuleIndicator(node);
|
||||
bindExportAssignment(node);
|
||||
}
|
||||
|
||||
function bindCallExpression(node: CallExpression) {
|
||||
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
|
||||
// this check if we've already seen the module indicator
|
||||
if (!file.commonJsModuleIndicator && isRequireCall(node)) {
|
||||
setCommonJsModuleIndicator(node);
|
||||
}
|
||||
}
|
||||
|
||||
function bindClassLikeDeclaration(node: ClassLikeDeclaration) {
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
|
||||
|
||||
+371
-166
File diff suppressed because it is too large
Load Diff
+13
-17
@@ -739,12 +739,7 @@ namespace ts {
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
export const supportedExtensions = [".ts", ".tsx", ".d.ts"];
|
||||
/**
|
||||
* List of extensions that will be used to look for external modules.
|
||||
* This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation,
|
||||
* but still would like to load only TypeScript files as modules
|
||||
*/
|
||||
export const moduleFileExtensions = supportedExtensions;
|
||||
export const supportedJsExtensions = supportedExtensions.concat(".js", ".jsx");
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string) {
|
||||
if (!fileName) { return false; }
|
||||
@@ -785,7 +780,8 @@ namespace ts {
|
||||
};
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node;
|
||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
||||
@@ -804,17 +800,17 @@ namespace ts {
|
||||
function Signature(checker: TypeChecker) {
|
||||
}
|
||||
|
||||
function Node(kind: SyntaxKind, pos: number, end: number) {
|
||||
this.kind = kind;
|
||||
this.pos = pos;
|
||||
this.end = end;
|
||||
this.flags = NodeFlags.None;
|
||||
this.parent = undefined;
|
||||
}
|
||||
|
||||
export let objectAllocator: ObjectAllocator = {
|
||||
getNodeConstructor: kind => {
|
||||
function Node(pos: number, end: number) {
|
||||
this.pos = pos;
|
||||
this.end = end;
|
||||
this.flags = NodeFlags.None;
|
||||
this.parent = undefined;
|
||||
}
|
||||
Node.prototype = { kind };
|
||||
return <any>Node;
|
||||
},
|
||||
getNodeConstructor: () => <any>Node,
|
||||
getSourceFileConstructor: () => <any>Node,
|
||||
getSymbolConstructor: () => <any>Symbol,
|
||||
getTypeConstructor: () => <any>Type,
|
||||
getSignatureConstructor: () => <any>Signature
|
||||
|
||||
@@ -45,18 +45,22 @@ namespace ts {
|
||||
let writeLine: () => void;
|
||||
let increaseIndent: () => void;
|
||||
let decreaseIndent: () => void;
|
||||
let writeTextOfNode: (sourceFile: SourceFile, node: Node) => void;
|
||||
let writeTextOfNode: (text: string, node: Node) => void;
|
||||
|
||||
let writer = createAndSetNewTextWriterWithSymbolWriter();
|
||||
|
||||
let enclosingDeclaration: Node;
|
||||
let currentSourceFile: SourceFile;
|
||||
let currentText: string;
|
||||
let currentLineMap: number[];
|
||||
let currentIdentifiers: Map<string>;
|
||||
let isCurrentFileExternalModule: boolean;
|
||||
let reportedDeclarationError = false;
|
||||
let errorNameNode: DeclarationName;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
let noDeclare = !root;
|
||||
|
||||
const moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[];
|
||||
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
@@ -104,15 +108,16 @@ namespace ts {
|
||||
else {
|
||||
// Emit references corresponding to this file
|
||||
const emittedReferencedFiles: SourceFile[] = [];
|
||||
let prevModuleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
const referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file or an external module, emit that reference
|
||||
if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
// If the reference file is a declaration file, emit that reference
|
||||
if (referencedFile && (isDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
@@ -120,10 +125,43 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
noDeclare = false;
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
else if (isExternalModule(sourceFile)) {
|
||||
noDeclare = true;
|
||||
write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitSourceFile(sourceFile);
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
writeLine();
|
||||
|
||||
// create asynchronous output for the importDeclarations
|
||||
if (moduleElementDeclarationEmitInfo.length) {
|
||||
const oldWriter = writer;
|
||||
forEach(moduleElementDeclarationEmitInfo, aliasEmitInfo => {
|
||||
if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) {
|
||||
Debug.assert(aliasEmitInfo.node.kind === SyntaxKind.ImportDeclaration);
|
||||
createAndSetNewTextWriterWithSymbolWriter();
|
||||
Debug.assert(aliasEmitInfo.indent === 1);
|
||||
increaseIndent();
|
||||
writeImportDeclaration(<ImportDeclaration>aliasEmitInfo.node);
|
||||
aliasEmitInfo.asynchronousOutput = writer.getText();
|
||||
decreaseIndent();
|
||||
}
|
||||
});
|
||||
setWriter(oldWriter);
|
||||
}
|
||||
prevModuleElementDeclarationEmitInfo = prevModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo);
|
||||
moduleElementDeclarationEmitInfo = [];
|
||||
}
|
||||
});
|
||||
moduleElementDeclarationEmitInfo = moduleElementDeclarationEmitInfo.concat(prevModuleElementDeclarationEmitInfo);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -134,14 +172,13 @@ namespace ts {
|
||||
};
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
const text = currentSourceFile.text;
|
||||
const comment = text.substring(range.pos, range.end);
|
||||
const comment = currentText.substring(range.pos, range.end);
|
||||
return comment.indexOf("@internal") >= 0;
|
||||
}
|
||||
|
||||
function stripInternal(node: Node) {
|
||||
if (node) {
|
||||
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
const leadingCommentRanges = getLeadingCommentRanges(currentText, node.pos);
|
||||
if (forEach(leadingCommentRanges, hasInternalAnnotation)) {
|
||||
return;
|
||||
}
|
||||
@@ -243,7 +280,7 @@ namespace ts {
|
||||
if (errorInfo.typeName) {
|
||||
diagnostics.push(createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName),
|
||||
getTextOfNodeFromSourceText(currentText, errorInfo.typeName),
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
}
|
||||
@@ -321,10 +358,10 @@ namespace ts {
|
||||
|
||||
function writeJsDocComments(declaration: Node) {
|
||||
if (declaration) {
|
||||
const jsDocComments = getJsDocComments(declaration, currentSourceFile);
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments);
|
||||
const jsDocComments = getJsDocCommentsFromText(declaration, currentText);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, declaration, jsDocComments);
|
||||
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
emitComments(currentText, currentLineMap, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +380,7 @@ namespace ts {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return writeTextOfNode(currentSourceFile, type);
|
||||
return writeTextOfNode(currentText, type);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>type);
|
||||
case SyntaxKind.TypeReference:
|
||||
@@ -375,14 +412,14 @@ namespace ts {
|
||||
|
||||
function writeEntityName(entityName: EntityName | Expression) {
|
||||
if (entityName.kind === SyntaxKind.Identifier) {
|
||||
writeTextOfNode(currentSourceFile, entityName);
|
||||
writeTextOfNode(currentText, entityName);
|
||||
}
|
||||
else {
|
||||
const left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
|
||||
const right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
|
||||
writeEntityName(left);
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, right);
|
||||
writeTextOfNode(currentText, right);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +454,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitTypePredicate(type: TypePredicateNode) {
|
||||
writeTextOfNode(currentSourceFile, type.parameterName);
|
||||
writeTextOfNode(currentText, type.parameterName);
|
||||
write(" is ");
|
||||
emitType(type.type);
|
||||
}
|
||||
@@ -466,9 +503,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitSourceFile(node: SourceFile) {
|
||||
currentSourceFile = node;
|
||||
currentText = node.text;
|
||||
currentLineMap = getLineStarts(node);
|
||||
currentIdentifiers = node.identifiers;
|
||||
isCurrentFileExternalModule = isExternalModule(node);
|
||||
enclosingDeclaration = node;
|
||||
emitDetachedComments(currentSourceFile, writer, writeCommentRange, node, newLine, true /* remove comments */);
|
||||
emitDetachedComments(currentText, currentLineMap, writer, writeCommentRange, node, newLine, true /* remove comments */);
|
||||
emitLines(node.statements);
|
||||
}
|
||||
|
||||
@@ -478,13 +518,13 @@ namespace ts {
|
||||
// do not need to keep track of created temp names.
|
||||
function getExportDefaultTempVariableName(): string {
|
||||
const baseName = "_default";
|
||||
if (!hasProperty(currentSourceFile.identifiers, baseName)) {
|
||||
if (!hasProperty(currentIdentifiers, baseName)) {
|
||||
return baseName;
|
||||
}
|
||||
let count = 0;
|
||||
while (true) {
|
||||
const name = baseName + "_" + (++count);
|
||||
if (!hasProperty(currentSourceFile.identifiers, name)) {
|
||||
if (!hasProperty(currentIdentifiers, name)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -493,7 +533,7 @@ namespace ts {
|
||||
function emitExportAssignment(node: ExportAssignment) {
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
writeTextOfNode(currentSourceFile, node.expression);
|
||||
writeTextOfNode(currentText, node.expression);
|
||||
}
|
||||
else {
|
||||
// Expression
|
||||
@@ -537,7 +577,7 @@ namespace ts {
|
||||
}
|
||||
// Import equals declaration in internal module can become visible as part of any emit so lets make sure we add these irrespective
|
||||
else if (node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
(node.parent.kind === SyntaxKind.SourceFile && isExternalModule(currentSourceFile))) {
|
||||
(node.parent.kind === SyntaxKind.SourceFile && isCurrentFileExternalModule)) {
|
||||
let isVisible: boolean;
|
||||
if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== SyntaxKind.SourceFile) {
|
||||
// Import declaration of another module that is visited async so lets put it in right spot
|
||||
@@ -593,7 +633,7 @@ namespace ts {
|
||||
|
||||
function emitModuleElementDeclarationFlags(node: Node) {
|
||||
// If the node is parented in the current source file we need to emit export declare or just export
|
||||
if (node.parent === currentSourceFile) {
|
||||
if (node.parent.kind === SyntaxKind.SourceFile) {
|
||||
// If the node is exported
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
write("export ");
|
||||
@@ -602,7 +642,7 @@ namespace ts {
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
write("default ");
|
||||
}
|
||||
else if (node.kind !== SyntaxKind.InterfaceDeclaration) {
|
||||
else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
}
|
||||
@@ -632,7 +672,7 @@ namespace ts {
|
||||
write("export ");
|
||||
}
|
||||
write("import ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
write(" = ");
|
||||
if (isInternalModuleImportEqualsDeclaration(node)) {
|
||||
emitTypeWithNewGetSymbolAccessibilityDiagnostic(<EntityName>node.moduleReference, getImportEntityNameVisibilityError);
|
||||
@@ -640,7 +680,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
write("require(");
|
||||
writeTextOfNode(currentSourceFile, getExternalModuleImportEqualsDeclarationExpression(node));
|
||||
writeTextOfNode(currentText, getExternalModuleImportEqualsDeclarationExpression(node));
|
||||
write(");");
|
||||
}
|
||||
writer.writeLine();
|
||||
@@ -678,7 +718,7 @@ namespace ts {
|
||||
if (node.importClause) {
|
||||
const currentWriterPos = writer.getTextPos();
|
||||
if (node.importClause.name && resolver.isDeclarationVisible(node.importClause)) {
|
||||
writeTextOfNode(currentSourceFile, node.importClause.name);
|
||||
writeTextOfNode(currentText, node.importClause.name);
|
||||
}
|
||||
if (node.importClause.namedBindings && isVisibleNamedBinding(node.importClause.namedBindings)) {
|
||||
if (currentWriterPos !== writer.getTextPos()) {
|
||||
@@ -687,7 +727,7 @@ namespace ts {
|
||||
}
|
||||
if (node.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
write("* as ");
|
||||
writeTextOfNode(currentSourceFile, (<NamespaceImport>node.importClause.namedBindings).name);
|
||||
writeTextOfNode(currentText, (<NamespaceImport>node.importClause.namedBindings).name);
|
||||
}
|
||||
else {
|
||||
write("{ ");
|
||||
@@ -697,17 +737,31 @@ namespace ts {
|
||||
}
|
||||
write(" from ");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node.moduleSpecifier);
|
||||
emitExternalModuleSpecifier(node.moduleSpecifier);
|
||||
write(";");
|
||||
writer.writeLine();
|
||||
}
|
||||
|
||||
function emitExternalModuleSpecifier(moduleSpecifier: Expression) {
|
||||
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && (!root) && (compilerOptions.out || compilerOptions.outFile)) {
|
||||
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, moduleSpecifier.parent as (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration));
|
||||
if (moduleName) {
|
||||
write("\"");
|
||||
write(moduleName);
|
||||
write("\"");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
writeTextOfNode(currentText, moduleSpecifier);
|
||||
}
|
||||
|
||||
function emitImportOrExportSpecifier(node: ImportOrExportSpecifier) {
|
||||
if (node.propertyName) {
|
||||
writeTextOfNode(currentSourceFile, node.propertyName);
|
||||
writeTextOfNode(currentText, node.propertyName);
|
||||
write(" as ");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
|
||||
function emitExportSpecifier(node: ExportSpecifier) {
|
||||
@@ -733,7 +787,7 @@ namespace ts {
|
||||
}
|
||||
if (node.moduleSpecifier) {
|
||||
write(" from ");
|
||||
writeTextOfNode(currentSourceFile, node.moduleSpecifier);
|
||||
emitExternalModuleSpecifier(node.moduleSpecifier);
|
||||
}
|
||||
write(";");
|
||||
writer.writeLine();
|
||||
@@ -748,11 +802,11 @@ namespace ts {
|
||||
else {
|
||||
write("module ");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
while (node.body.kind !== SyntaxKind.ModuleBlock) {
|
||||
node = <ModuleDeclaration>node.body;
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
@@ -772,7 +826,7 @@ namespace ts {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("type ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
emitTypeParameters(node.typeParameters);
|
||||
write(" = ");
|
||||
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError);
|
||||
@@ -796,7 +850,7 @@ namespace ts {
|
||||
write("const ");
|
||||
}
|
||||
write("enum ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
@@ -808,7 +862,7 @@ namespace ts {
|
||||
|
||||
function emitEnumMemberDeclaration(node: EnumMember) {
|
||||
emitJsDocComments(node);
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
const enumMemberValue = resolver.getConstantValue(node);
|
||||
if (enumMemberValue !== undefined) {
|
||||
write(" = ");
|
||||
@@ -827,7 +881,7 @@ namespace ts {
|
||||
increaseIndent();
|
||||
emitJsDocComments(node);
|
||||
decreaseIndent();
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If there is constraint present and this is not a type parameter of the private method emit the constraint
|
||||
if (node.constraint && !isPrivateMethodTypeParameter(node)) {
|
||||
write(" extends ");
|
||||
@@ -958,7 +1012,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
write("class ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
@@ -982,7 +1036,7 @@ namespace ts {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("interface ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
@@ -1020,7 +1074,7 @@ namespace ts {
|
||||
// If this node is a computed name, it can only be a symbol, because we've already skipped
|
||||
// it if it's not a well known symbol. In that case, the text of the name will be exactly
|
||||
// what we want, namely the name expression enclosed in brackets.
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If optional property emit ?
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
@@ -1107,7 +1161,7 @@ namespace ts {
|
||||
emitBindingPattern(<BindingPattern>bindingElement.name);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, bindingElement.name);
|
||||
writeTextOfNode(currentText, bindingElement.name);
|
||||
writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError);
|
||||
}
|
||||
}
|
||||
@@ -1157,7 +1211,7 @@ namespace ts {
|
||||
emitJsDocComments(accessors.getAccessor);
|
||||
emitJsDocComments(accessors.setAccessor);
|
||||
emitClassMemberDeclarationFlags(node);
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
if (!(node.flags & NodeFlags.Private)) {
|
||||
accessorWithTypeAnnotation = node;
|
||||
let type = getTypeAnnotationFromAccessor(node);
|
||||
@@ -1247,13 +1301,13 @@ namespace ts {
|
||||
}
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
write("function ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Constructor) {
|
||||
write("constructor");
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
if (hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
@@ -1393,7 +1447,7 @@ namespace ts {
|
||||
emitBindingPattern(<BindingPattern>node.name);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
}
|
||||
if (resolver.isOptionalParameter(node)) {
|
||||
write("?");
|
||||
@@ -1519,7 +1573,7 @@ namespace ts {
|
||||
// Example:
|
||||
// original: function foo({y: [a,b,c]}) {}
|
||||
// emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void;
|
||||
writeTextOfNode(currentSourceFile, bindingElement.propertyName);
|
||||
writeTextOfNode(currentText, bindingElement.propertyName);
|
||||
write(": ");
|
||||
}
|
||||
if (bindingElement.name) {
|
||||
@@ -1542,7 +1596,7 @@ namespace ts {
|
||||
if (bindingElement.dotDotDotToken) {
|
||||
write("...");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, bindingElement.name);
|
||||
writeTextOfNode(currentText, bindingElement.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2310,7 +2310,6 @@
|
||||
"category": "Message",
|
||||
"code": 6078
|
||||
},
|
||||
|
||||
"Specify JSX code generation: 'preserve' or 'react'": {
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
@@ -2319,7 +2318,10 @@
|
||||
"category": "Message",
|
||||
"code": 6081
|
||||
},
|
||||
|
||||
"Only 'amd' and 'system' modules are supported alongside --{0}.": {
|
||||
"category": "Error",
|
||||
"code": 6082
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
+214
-109
@@ -7,6 +7,18 @@ namespace ts {
|
||||
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
|
||||
}
|
||||
|
||||
export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string {
|
||||
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
|
||||
}
|
||||
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string {
|
||||
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
||||
if (!file || isDeclarationFile(file)) {
|
||||
return undefined;
|
||||
}
|
||||
return getResolvedExternalModuleName(host, file);
|
||||
}
|
||||
|
||||
type DependencyGroup = Array<ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration>;
|
||||
|
||||
const enum Jump {
|
||||
@@ -332,17 +344,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
const newLine = host.getNewLine();
|
||||
const jsxDesugaring = host.getCompilerOptions().jsx !== JsxEmit.Preserve;
|
||||
const shouldEmitJsx = (s: SourceFile) => (s.languageVariant === LanguageVariant.JSX && !jsxDesugaring);
|
||||
const outFile = compilerOptions.outFile || compilerOptions.out;
|
||||
|
||||
const emitJavaScript = createFileEmitter();
|
||||
|
||||
if (targetSourceFile === undefined) {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
|
||||
if (compilerOptions.outFile || compilerOptions.out) {
|
||||
emitFile(compilerOptions.outFile || compilerOptions.out);
|
||||
if (outFile) {
|
||||
emitFile(outFile);
|
||||
}
|
||||
else {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||
const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -351,8 +367,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
const jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) {
|
||||
emitFile(compilerOptions.outFile || compilerOptions.out);
|
||||
else if (!isDeclarationFile(targetSourceFile) && outFile) {
|
||||
emitFile(outFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,11 +486,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitJavaScript(jsFilePath: string, root?: SourceFile) {
|
||||
const writer = createTextWriter(newLine);
|
||||
function createFileEmitter(): (jsFilePath: string, root?: SourceFile) => void {
|
||||
const writer: EmitTextWriter = createTextWriter(newLine);
|
||||
const { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
let currentText: string;
|
||||
let currentLineMap: number[];
|
||||
let currentFileIdentifiers: Map<string>;
|
||||
let renamedDependencies: Map<string>;
|
||||
let isEs6Module: boolean;
|
||||
let isCurrentFileExternalModule: boolean;
|
||||
|
||||
// name of an exporter function if file is a System external module
|
||||
// System.register([...], function (<exporter>) {...})
|
||||
// exporting in System modules looks like:
|
||||
@@ -483,17 +506,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// var x;... exporter("x", x = 1)
|
||||
let exportFunctionForFile: string;
|
||||
|
||||
const generatedNameSet: Map<string> = {};
|
||||
const nodeToGeneratedName: string[] = [];
|
||||
let generatedNameSet: Map<string>;
|
||||
let nodeToGeneratedName: string[];
|
||||
let computedPropertyNamesToGeneratedNames: string[];
|
||||
|
||||
let convertedLoopState: ConvertedLoopState;
|
||||
|
||||
let extendsEmitted = false;
|
||||
let decorateEmitted = false;
|
||||
let paramEmitted = false;
|
||||
let awaiterEmitted = false;
|
||||
let tempFlags = 0;
|
||||
let extendsEmitted: boolean;
|
||||
let decorateEmitted: boolean;
|
||||
let paramEmitted: boolean;
|
||||
let awaiterEmitted: boolean;
|
||||
let tempFlags: TempFlags;
|
||||
let tempVariables: Identifier[];
|
||||
let tempParameters: Identifier[];
|
||||
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
|
||||
@@ -536,10 +559,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
/** Sourcemap data that will get encoded */
|
||||
let sourceMapData: SourceMapData;
|
||||
|
||||
/** The root file passed to the emit function (if present) */
|
||||
let root: SourceFile;
|
||||
|
||||
/** If removeComments is true, no leading-comments needed to be emitted **/
|
||||
const emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
|
||||
|
||||
const moduleEmitDelegates: Map<(node: SourceFile) => void> = {
|
||||
const moduleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = {
|
||||
[ModuleKind.ES6]: emitES6Module,
|
||||
[ModuleKind.AMD]: emitAMDModule,
|
||||
[ModuleKind.System]: emitSystemModule,
|
||||
@@ -547,35 +573,86 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
[ModuleKind.CommonJS]: emitCommonJSModule,
|
||||
};
|
||||
|
||||
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
|
||||
initializeEmitterWithSourceMaps();
|
||||
}
|
||||
const bundleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = {
|
||||
[ModuleKind.ES6]() {},
|
||||
[ModuleKind.AMD]: emitAMDModule,
|
||||
[ModuleKind.System]: emitSystemModule,
|
||||
[ModuleKind.UMD]() {},
|
||||
[ModuleKind.CommonJS]() {},
|
||||
};
|
||||
|
||||
if (root) {
|
||||
// Do not call emit directly. It does not set the currentSourceFile.
|
||||
emitSourceFile(root);
|
||||
}
|
||||
else {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
emitSourceFile(sourceFile);
|
||||
return doEmit;
|
||||
|
||||
function doEmit(jsFilePath: string, rootFile?: SourceFile) {
|
||||
// reset the state
|
||||
writer.reset();
|
||||
currentSourceFile = undefined;
|
||||
currentText = undefined;
|
||||
currentLineMap = undefined;
|
||||
exportFunctionForFile = undefined;
|
||||
generatedNameSet = {};
|
||||
nodeToGeneratedName = [];
|
||||
computedPropertyNamesToGeneratedNames = undefined;
|
||||
convertedLoopState = undefined;
|
||||
|
||||
extendsEmitted = false;
|
||||
decorateEmitted = false;
|
||||
paramEmitted = false;
|
||||
awaiterEmitted = false;
|
||||
tempFlags = 0;
|
||||
tempVariables = undefined;
|
||||
tempParameters = undefined;
|
||||
externalImports = undefined;
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = undefined;
|
||||
detachedCommentsInfo = undefined;
|
||||
sourceMapData = undefined;
|
||||
isEs6Module = false;
|
||||
renamedDependencies = undefined;
|
||||
isCurrentFileExternalModule = false;
|
||||
root = rootFile;
|
||||
|
||||
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
|
||||
initializeEmitterWithSourceMaps(jsFilePath, root);
|
||||
}
|
||||
|
||||
if (root) {
|
||||
// Do not call emit directly. It does not set the currentSourceFile.
|
||||
emitSourceFile(root);
|
||||
}
|
||||
else {
|
||||
if (modulekind) {
|
||||
forEach(host.getSourceFiles(), emitEmitHelpers);
|
||||
}
|
||||
});
|
||||
}
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if ((!isExternalModuleOrDeclarationFile(sourceFile)) || (modulekind && isExternalModule(sourceFile))) {
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
writeLine();
|
||||
writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM);
|
||||
return;
|
||||
writeLine();
|
||||
writeEmittedFiles(writer.getText(), jsFilePath, /*writeByteOrderMark*/ compilerOptions.emitBOM);
|
||||
}
|
||||
|
||||
function emitSourceFile(sourceFile: SourceFile): void {
|
||||
currentSourceFile = sourceFile;
|
||||
|
||||
currentText = sourceFile.text;
|
||||
currentLineMap = getLineStarts(sourceFile);
|
||||
exportFunctionForFile = undefined;
|
||||
isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"];
|
||||
renamedDependencies = sourceFile.renamedDependencies;
|
||||
currentFileIdentifiers = sourceFile.identifiers;
|
||||
isCurrentFileExternalModule = isExternalModule(sourceFile);
|
||||
|
||||
emit(sourceFile);
|
||||
}
|
||||
|
||||
function isUniqueName(name: string): boolean {
|
||||
return !resolver.hasGlobalName(name) &&
|
||||
!hasProperty(currentSourceFile.identifiers, name) &&
|
||||
!hasProperty(currentFileIdentifiers, name) &&
|
||||
!hasProperty(generatedNameSet, name);
|
||||
}
|
||||
|
||||
@@ -667,7 +744,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateNameForNode(node)));
|
||||
}
|
||||
|
||||
function initializeEmitterWithSourceMaps() {
|
||||
function initializeEmitterWithSourceMaps(jsFilePath: string, root?: SourceFile) {
|
||||
let sourceMapDir: string; // The directory in which sourcemap will be
|
||||
|
||||
// Current source map file and its index in the sources list
|
||||
@@ -771,7 +848,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function recordSourceMapSpan(pos: number) {
|
||||
const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos);
|
||||
const sourceLinePos = computeLineAndCharacterOfPosition(currentLineMap, pos);
|
||||
|
||||
// Convert the location to be one-based.
|
||||
sourceLinePos.line++;
|
||||
@@ -810,7 +887,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
function recordEmitNodeStartSpan(node: Node) {
|
||||
// Get the token pos after skipping to the token (ignoring the leading trivia)
|
||||
recordSourceMapSpan(skipTrivia(currentSourceFile.text, node.pos));
|
||||
recordSourceMapSpan(skipTrivia(currentText, node.pos));
|
||||
}
|
||||
|
||||
function recordEmitNodeEndSpan(node: Node) {
|
||||
@@ -818,7 +895,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function writeTextWithSpanRecord(tokenKind: SyntaxKind, startPos: number, emitFn?: () => void) {
|
||||
const tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos);
|
||||
const tokenStartPos = ts.skipTrivia(currentText, startPos);
|
||||
recordSourceMapSpan(tokenStartPos);
|
||||
const tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn);
|
||||
recordSourceMapSpan(tokenEndPos);
|
||||
@@ -912,9 +989,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
sourceMapNameIndices.pop();
|
||||
};
|
||||
|
||||
function writeCommentRangeWithMap(curentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) {
|
||||
function writeCommentRangeWithMap(currentText: string, currentLineMap: number[], writer: EmitTextWriter, comment: CommentRange, newLine: string) {
|
||||
recordSourceMapSpan(comment.pos);
|
||||
writeCommentRange(currentSourceFile, writer, comment, newLine);
|
||||
writeCommentRange(currentText, currentLineMap, writer, comment, newLine);
|
||||
recordSourceMapSpan(comment.end);
|
||||
}
|
||||
|
||||
@@ -950,7 +1027,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) {
|
||||
function writeJavaScriptAndSourceMapFile(emitOutput: string, jsFilePath: string, writeByteOrderMark: boolean) {
|
||||
encodeLastRecordedSourceMapSpan();
|
||||
|
||||
const sourceMapText = serializeSourceMapContents(
|
||||
@@ -977,7 +1054,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
// Write sourcemap url to the js file and write the js file
|
||||
writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark);
|
||||
writeJavaScriptFile(emitOutput + sourceMapUrl, jsFilePath, writeByteOrderMark);
|
||||
}
|
||||
|
||||
// Initialize source map data
|
||||
@@ -1059,7 +1136,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
writeComment = writeCommentRangeWithMap;
|
||||
}
|
||||
|
||||
function writeJavaScriptFile(emitOutput: string, writeByteOrderMark: boolean) {
|
||||
function writeJavaScriptFile(emitOutput: string, jsFilePath: string, writeByteOrderMark: boolean) {
|
||||
writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark);
|
||||
}
|
||||
|
||||
@@ -1269,7 +1346,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// If we don't need to downlevel and we can reach the original source text using
|
||||
// the node's parent reference, then simply get the text as it was originally written.
|
||||
if (node.parent) {
|
||||
return getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
|
||||
return getTextOfNodeFromSourceText(currentText, node);
|
||||
}
|
||||
|
||||
// If we can't reach the original source text, use the canonical form if it's a number,
|
||||
@@ -1300,7 +1377,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// Find original source text, since we need to emit the raw strings of the tagged template.
|
||||
// The raw strings contain the (escaped) strings of what the user wrote.
|
||||
// Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
|
||||
let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
|
||||
let text = getTextOfNodeFromSourceText(currentText, node);
|
||||
|
||||
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
|
||||
// thus we need to remove those characters.
|
||||
@@ -1772,7 +1849,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write((<LiteralExpression>node).text);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
writeTextOfNode(currentText, node);
|
||||
}
|
||||
|
||||
write("\"");
|
||||
@@ -1876,7 +1953,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// Identifier references named import
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent.parent.parent));
|
||||
const name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name;
|
||||
const identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name);
|
||||
const identifier = getTextOfNodeFromSourceText(currentText, name);
|
||||
if (languageVersion === ScriptTarget.ES3 && identifier === "default") {
|
||||
write(`["default"]`);
|
||||
}
|
||||
@@ -1902,7 +1979,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(node.text);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
writeTextOfNode(currentText, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1943,7 +2020,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(node.text);
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
writeTextOfNode(currentText, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2403,7 +2480,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) {
|
||||
// The name property of a short-hand property assignment is considered an expression position, so here
|
||||
// we manually emit the identifier to avoid rewriting.
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier,
|
||||
// we emit a normal property assignment. For example:
|
||||
// module m {
|
||||
@@ -2413,7 +2490,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// let obj = { y };
|
||||
// }
|
||||
// Here we need to emit obj = { y : m.y } regardless of the output target.
|
||||
if (languageVersion < ScriptTarget.ES6 || isNamespaceExportReference(node.name)) {
|
||||
if (modulekind !== ModuleKind.ES6 || isNamespaceExportReference(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
emit(node.name);
|
||||
@@ -2480,11 +2557,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
// 1 .toString is a valid property access, emit a space after the literal
|
||||
// Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal
|
||||
let shouldEmitSpace: boolean;
|
||||
let shouldEmitSpace = false;
|
||||
if (!indentedBeforeDot) {
|
||||
if (node.expression.kind === SyntaxKind.NumericLiteral) {
|
||||
// check if numeric literal was originally written with a dot
|
||||
const text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression);
|
||||
const text = getTextOfNodeFromSourceText(currentText, node.expression);
|
||||
shouldEmitSpace = text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
|
||||
}
|
||||
else {
|
||||
@@ -3815,18 +3892,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function nodeStartPositionsAreOnSameLine(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) ===
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
return getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node1.pos)) ===
|
||||
getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node2.pos));
|
||||
}
|
||||
|
||||
function nodeEndPositionsAreOnSameLine(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, node1.end) ===
|
||||
getLineOfLocalPosition(currentSourceFile, node2.end);
|
||||
return getLineOfLocalPositionFromLineMap(currentLineMap, node1.end) ===
|
||||
getLineOfLocalPositionFromLineMap(currentLineMap, node2.end);
|
||||
}
|
||||
|
||||
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, node1.end) ===
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
return getLineOfLocalPositionFromLineMap(currentLineMap, node1.end) ===
|
||||
getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node2.pos));
|
||||
}
|
||||
|
||||
function emitCaseOrDefaultClause(node: CaseOrDefaultClause) {
|
||||
@@ -3948,7 +4025,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment);
|
||||
// only allow export default at a source file level
|
||||
if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) {
|
||||
if (!currentSourceFile.symbol.exports["___esModule"]) {
|
||||
if (!isEs6Module) {
|
||||
if (languageVersion === ScriptTarget.ES5) {
|
||||
// default value of configurable, enumerable, writable are `false`.
|
||||
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
|
||||
@@ -4167,15 +4244,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return node;
|
||||
}
|
||||
|
||||
function createPropertyAccessForDestructuringProperty(object: Expression, propName: Identifier | LiteralExpression): Expression {
|
||||
// We create a synthetic copy of the identifier in order to avoid the rewriting that might
|
||||
// otherwise occur when the identifier is emitted.
|
||||
const syntheticName = <Identifier | LiteralExpression>createSynthesizedNode(propName.kind);
|
||||
syntheticName.text = propName.text;
|
||||
if (syntheticName.kind !== SyntaxKind.Identifier) {
|
||||
return createElementAccessExpression(object, syntheticName);
|
||||
function createPropertyAccessForDestructuringProperty(object: Expression, propName: PropertyName): Expression {
|
||||
let index: Expression;
|
||||
const nameIsComputed = propName.kind === SyntaxKind.ComputedPropertyName;
|
||||
if (nameIsComputed) {
|
||||
index = ensureIdentifier((<ComputedPropertyName>propName).expression, /* reuseIdentifierExpression */ false);
|
||||
}
|
||||
return createPropertyAccessExpression(object, syntheticName);
|
||||
else {
|
||||
// We create a synthetic copy of the identifier in order to avoid the rewriting that might
|
||||
// otherwise occur when the identifier is emitted.
|
||||
index = <Identifier | LiteralExpression>createSynthesizedNode(propName.kind);
|
||||
(<Identifier | LiteralExpression>index).text = (<Identifier | LiteralExpression>propName).text;
|
||||
}
|
||||
|
||||
return !nameIsComputed && index.kind === SyntaxKind.Identifier
|
||||
? createPropertyAccessExpression(object, <Identifier>index)
|
||||
: createElementAccessExpression(object, index);
|
||||
}
|
||||
|
||||
function createSliceCall(value: Expression, sliceIndex: number): CallExpression {
|
||||
@@ -6304,8 +6388,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
* Here we check if alternative name was provided for a given moduleName and return it if possible.
|
||||
*/
|
||||
function tryRenameExternalModule(moduleName: LiteralExpression): string {
|
||||
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
|
||||
return `"${currentSourceFile.renamedDependencies[moduleName.text]}"`;
|
||||
if (renamedDependencies && hasProperty(renamedDependencies, moduleName.text)) {
|
||||
return `"${renamedDependencies[moduleName.text]}"`;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -6467,7 +6551,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// - current file is not external module
|
||||
// - import declaration is top level and target is value imported by entity name
|
||||
if (resolver.isReferencedAliasDeclaration(node) ||
|
||||
(!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) {
|
||||
(!isCurrentFileExternalModule && resolver.isTopLevelValueImportEqualsWithEntityName(node))) {
|
||||
emitLeadingComments(node);
|
||||
emitStart(node);
|
||||
|
||||
@@ -6708,7 +6792,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
|
||||
const namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
return getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name);
|
||||
return getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name);
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause) {
|
||||
return getGeneratedNameForNode(node);
|
||||
@@ -7064,7 +7148,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function isCurrentFileSystemExternalModule() {
|
||||
return modulekind === ModuleKind.System && isExternalModule(currentSourceFile);
|
||||
return modulekind === ModuleKind.System && isCurrentFileExternalModule;
|
||||
}
|
||||
|
||||
function emitSystemModuleBody(node: SourceFile, dependencyGroups: DependencyGroup[], startIndex: number): void {
|
||||
@@ -7249,7 +7333,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write("}"); // execute
|
||||
}
|
||||
|
||||
function emitSystemModule(node: SourceFile): void {
|
||||
function writeModuleName(node: SourceFile, emitRelativePathAsModuleName?: boolean): void {
|
||||
let moduleName = node.moduleName;
|
||||
if (moduleName || (emitRelativePathAsModuleName && (moduleName = getResolvedExternalModuleName(host, node)))) {
|
||||
write(`"${moduleName}", `);
|
||||
}
|
||||
}
|
||||
|
||||
function emitSystemModule(node: SourceFile, emitRelativePathAsModuleName?: boolean): void {
|
||||
collectExternalModuleInfo(node);
|
||||
// System modules has the following shape
|
||||
// System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */})
|
||||
@@ -7264,16 +7355,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
exportFunctionForFile = makeUniqueName("exports");
|
||||
writeLine();
|
||||
write("System.register(");
|
||||
if (node.moduleName) {
|
||||
write(`"${node.moduleName}", `);
|
||||
}
|
||||
writeModuleName(node, emitRelativePathAsModuleName);
|
||||
write("[");
|
||||
|
||||
const groupIndices: Map<number> = {};
|
||||
const dependencyGroups: DependencyGroup[] = [];
|
||||
|
||||
for (let i = 0; i < externalImports.length; ++i) {
|
||||
const text = getExternalModuleNameText(externalImports[i]);
|
||||
let text = getExternalModuleNameText(externalImports[i]);
|
||||
if (hasProperty(groupIndices, text)) {
|
||||
// deduplicate/group entries in dependency list by the dependency name
|
||||
const groupIndex = groupIndices[text];
|
||||
@@ -7289,6 +7378,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(", ");
|
||||
}
|
||||
|
||||
if (emitRelativePathAsModuleName) {
|
||||
const name = getExternalModuleNameFromDeclaration(host, resolver, externalImports[i]);
|
||||
if (name) {
|
||||
text = `"${name}"`;
|
||||
}
|
||||
}
|
||||
write(text);
|
||||
}
|
||||
write(`], function(${exportFunctionForFile}) {`);
|
||||
@@ -7309,7 +7404,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
importAliasNames: string[];
|
||||
}
|
||||
|
||||
function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean): AMDDependencyNames {
|
||||
function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean, emitRelativePathAsModuleName?: boolean): AMDDependencyNames {
|
||||
// names of modules with corresponding parameter in the factory function
|
||||
const aliasedModuleNames: string[] = [];
|
||||
// names of modules with no corresponding parameters in factory function
|
||||
@@ -7331,7 +7426,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
for (const importNode of externalImports) {
|
||||
// Find the name of the external module
|
||||
const externalModuleName = getExternalModuleNameText(importNode);
|
||||
let externalModuleName = getExternalModuleNameText(importNode);
|
||||
|
||||
if (emitRelativePathAsModuleName) {
|
||||
const name = getExternalModuleNameFromDeclaration(host, resolver, importNode);
|
||||
if (name) {
|
||||
externalModuleName = `"${name}"`;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the name of the module alias, if there is one
|
||||
const importAliasName = getLocalNameForExternalImport(importNode);
|
||||
@@ -7347,7 +7449,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return { aliasedModuleNames, unaliasedModuleNames, importAliasNames };
|
||||
}
|
||||
|
||||
function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) {
|
||||
function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean, emitRelativePathAsModuleName?: boolean) {
|
||||
// An AMD define function has the following shape:
|
||||
// define(id?, dependencies?, factory);
|
||||
//
|
||||
@@ -7360,7 +7462,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// `import "module"` or `<amd-dependency path= "a.css" />`
|
||||
// we need to add modules without alias names to the end of the dependencies list
|
||||
|
||||
const dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies);
|
||||
const dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies, emitRelativePathAsModuleName);
|
||||
emitAMDDependencyList(dependencyNames);
|
||||
write(", ");
|
||||
emitAMDFactoryHeader(dependencyNames);
|
||||
@@ -7388,16 +7490,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(") {");
|
||||
}
|
||||
|
||||
function emitAMDModule(node: SourceFile) {
|
||||
function emitAMDModule(node: SourceFile, emitRelativePathAsModuleName?: boolean) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
writeLine();
|
||||
write("define(");
|
||||
if (node.moduleName) {
|
||||
write("\"" + node.moduleName + "\", ");
|
||||
}
|
||||
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
|
||||
writeModuleName(node, emitRelativePathAsModuleName);
|
||||
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName);
|
||||
increaseIndent();
|
||||
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true);
|
||||
emitExportStarHelper();
|
||||
@@ -7646,8 +7746,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emitDetachedCommentsAndUpdateCommentsInfo(node);
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
const emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS];
|
||||
emitModule(node);
|
||||
if (root || (!isExternalModule(node) && compilerOptions.isolatedModules)) {
|
||||
const emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS];
|
||||
emitModule(node);
|
||||
}
|
||||
else {
|
||||
bundleEmitDelegates[modulekind](node, /*emitRelativePathAsModuleName*/true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// emit prologue directives prior to __extends
|
||||
@@ -7927,7 +8032,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
function getLeadingCommentsWithoutDetachedComments() {
|
||||
// get the leading comments from detachedPos
|
||||
const leadingComments = getLeadingCommentRanges(currentSourceFile.text,
|
||||
const leadingComments = getLeadingCommentRanges(currentText,
|
||||
lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos);
|
||||
if (detachedCommentsInfo.length - 1) {
|
||||
detachedCommentsInfo.pop();
|
||||
@@ -7947,10 +8052,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function isTripleSlashComment(comment: CommentRange) {
|
||||
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
||||
// so that we don't end up computing comment string and doing match for all // comments
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
|
||||
if (currentText.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
|
||||
comment.pos + 2 < comment.end &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) {
|
||||
const textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
|
||||
currentText.charCodeAt(comment.pos + 2) === CharacterCodes.slash) {
|
||||
const textSubStr = currentText.substring(comment.pos, comment.end);
|
||||
return textSubStr.match(fullTripleSlashReferencePathRegEx) ||
|
||||
textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ?
|
||||
true : false;
|
||||
@@ -7968,7 +8073,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else {
|
||||
// get the leading comments from the node
|
||||
return getLeadingCommentRangesOfNode(node, currentSourceFile);
|
||||
return getLeadingCommentRangesOfNodeFromText(node, currentText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7978,7 +8083,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments
|
||||
if (node.parent) {
|
||||
if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) {
|
||||
return getTrailingCommentRanges(currentSourceFile.text, node.end);
|
||||
return getTrailingCommentRanges(currentText, node.end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8017,10 +8122,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, node, leadingComments);
|
||||
|
||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
|
||||
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitTrailingComments(node: Node) {
|
||||
@@ -8032,7 +8137,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
const trailingComments = getTrailingCommentsToEmit(node);
|
||||
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
|
||||
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
|
||||
emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8045,10 +8150,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return;
|
||||
}
|
||||
|
||||
const trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos);
|
||||
const trailingComments = getTrailingCommentRanges(currentText, pos);
|
||||
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
|
||||
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitLeadingCommentsOfPositionWorker(pos: number) {
|
||||
@@ -8063,17 +8168,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else {
|
||||
// get the leading comments from the node
|
||||
leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos);
|
||||
leadingComments = getLeadingCommentRanges(currentText, pos);
|
||||
}
|
||||
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, { pos: pos, end: pos }, leadingComments);
|
||||
|
||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitDetachedCommentsAndUpdateCommentsInfo(node: TextRange) {
|
||||
const currentDetachedCommentInfo = emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments);
|
||||
const currentDetachedCommentInfo = emitDetachedComments(currentText, currentLineMap, writer, writeComment, node, newLine, compilerOptions.removeComments);
|
||||
|
||||
if (currentDetachedCommentInfo) {
|
||||
if (detachedCommentsInfo) {
|
||||
@@ -8086,7 +8191,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitShebang() {
|
||||
const shebang = getShebang(currentSourceFile.text);
|
||||
const shebang = getShebang(currentText);
|
||||
if (shebang) {
|
||||
write(shebang);
|
||||
}
|
||||
|
||||
+46
-27
@@ -1,16 +1,19 @@
|
||||
/// <reference path="scanner.ts"/>
|
||||
/// <reference path="utilities.ts"/>
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
namespace ts {
|
||||
const nodeConstructors = new Array<new (pos: number, end: number) => Node>(SyntaxKind.Count);
|
||||
/* @internal */ export let parseTime = 0;
|
||||
|
||||
export function getNodeConstructor(kind: SyntaxKind): new (pos?: number, end?: number) => Node {
|
||||
return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
|
||||
}
|
||||
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
|
||||
export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node {
|
||||
return new (getNodeConstructor(kind))(pos, end);
|
||||
if (kind === SyntaxKind.SourceFile) {
|
||||
return new (SourceFileConstructor || (SourceFileConstructor = objectAllocator.getSourceFileConstructor()))(kind, pos, end);
|
||||
}
|
||||
else {
|
||||
return new (NodeConstructor || (NodeConstructor = objectAllocator.getNodeConstructor()))(kind, pos, end);
|
||||
}
|
||||
}
|
||||
|
||||
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
|
||||
@@ -437,6 +440,10 @@ namespace ts {
|
||||
const scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
|
||||
const disallowInAndDecoratorContext = ParserContextFlags.DisallowIn | ParserContextFlags.Decorator;
|
||||
|
||||
// capture constructors in 'initializeState' to avoid null checks
|
||||
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
|
||||
|
||||
let sourceFile: SourceFile;
|
||||
let parseDiagnostics: Diagnostic[];
|
||||
let syntaxCursor: IncrementalParser.SyntaxCursor;
|
||||
@@ -527,7 +534,8 @@ namespace ts {
|
||||
let parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile {
|
||||
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor);
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0;
|
||||
initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor);
|
||||
|
||||
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes);
|
||||
|
||||
@@ -536,7 +544,10 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor) {
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
|
||||
|
||||
sourceText = _sourceText;
|
||||
syntaxCursor = _syntaxCursor;
|
||||
|
||||
@@ -546,14 +557,14 @@ namespace ts {
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
|
||||
contextFlags = isJavaScript(fileName) ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None;
|
||||
contextFlags = isJavaScriptFile ? ParserContextFlags.JavaScriptFile : ParserContextFlags.None;
|
||||
parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
// Initialize and prime the scanner before parsing the source elements.
|
||||
scanner.setText(sourceText);
|
||||
scanner.setOnError(scanError);
|
||||
scanner.setScriptTarget(languageVersion);
|
||||
scanner.setLanguageVariant(isTsx(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard);
|
||||
scanner.setLanguageVariant(allowsJsxExpressions(fileName) ? LanguageVariant.JSX : LanguageVariant.Standard);
|
||||
}
|
||||
|
||||
function clearState() {
|
||||
@@ -572,6 +583,10 @@ namespace ts {
|
||||
function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean): SourceFile {
|
||||
sourceFile = createSourceFile(fileName, languageVersion);
|
||||
|
||||
if (contextFlags & ParserContextFlags.JavaScriptFile) {
|
||||
sourceFile.parserContextFlags = ParserContextFlags.JavaScriptFile;
|
||||
}
|
||||
|
||||
// Prime the scanner.
|
||||
token = nextToken();
|
||||
processReferenceComments(sourceFile);
|
||||
@@ -594,7 +609,7 @@ namespace ts {
|
||||
// If this is a javascript file, proactively see if we can get JSDoc comments for
|
||||
// relevant nodes in the file. We'll use these to provide typing informaion if they're
|
||||
// available.
|
||||
if (isJavaScript(fileName)) {
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
addJSDocComments();
|
||||
}
|
||||
|
||||
@@ -657,21 +672,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createSourceFile(fileName: string, languageVersion: ScriptTarget): SourceFile {
|
||||
const sourceFile = <SourceFile>createNode(SyntaxKind.SourceFile, /*pos*/ 0);
|
||||
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
|
||||
// this is quite rare comparing to other nodes and createNode should be as fast as possible
|
||||
const sourceFile = <SourceFile>new SourceFileConstructor(SyntaxKind.SourceFile, /*pos*/ 0, /* end */ sourceText.length);
|
||||
nodeCount++;
|
||||
|
||||
sourceFile.pos = 0;
|
||||
sourceFile.end = sourceText.length;
|
||||
sourceFile.text = sourceText;
|
||||
sourceFile.bindDiagnostics = [];
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.languageVariant = isTsx(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
sourceFile.languageVariant = allowsJsxExpressions(sourceFile.fileName) ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
function setContextFlag(val: Boolean, flag: ParserContextFlags) {
|
||||
function setContextFlag(val: boolean, flag: ParserContextFlags) {
|
||||
if (val) {
|
||||
contextFlags |= flag;
|
||||
}
|
||||
@@ -991,12 +1007,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// note: this function creates only node
|
||||
function createNode(kind: SyntaxKind, pos?: number): Node {
|
||||
nodeCount++;
|
||||
if (!(pos >= 0)) {
|
||||
pos = scanner.getStartPos();
|
||||
}
|
||||
return new (nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind)))(pos, pos);
|
||||
|
||||
return new NodeConstructor(kind, pos, pos);
|
||||
}
|
||||
|
||||
function finishNode<T extends Node>(node: T, end?: number): T {
|
||||
@@ -1069,7 +1087,7 @@ namespace ts {
|
||||
token === SyntaxKind.NumericLiteral;
|
||||
}
|
||||
|
||||
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): DeclarationName {
|
||||
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName {
|
||||
if (token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral) {
|
||||
return parseLiteralNode(/*internName*/ true);
|
||||
}
|
||||
@@ -1079,7 +1097,7 @@ namespace ts {
|
||||
return parseIdentifierName();
|
||||
}
|
||||
|
||||
function parsePropertyName(): DeclarationName {
|
||||
function parsePropertyName(): PropertyName {
|
||||
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true);
|
||||
}
|
||||
|
||||
@@ -1189,7 +1207,7 @@ namespace ts {
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName();
|
||||
case ParsingContext.ObjectBindingElements:
|
||||
return isLiteralPropertyName();
|
||||
return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
|
||||
case ParsingContext.HeritageClauseElement:
|
||||
// If we see { } then only consume it as an expression if it is followed by , or {
|
||||
// That way we won't consume the body of a class in its heritage clause.
|
||||
@@ -1979,9 +1997,7 @@ namespace ts {
|
||||
|
||||
function parseParameterType(): TypeNode {
|
||||
if (parseOptional(SyntaxKind.ColonToken)) {
|
||||
return token === SyntaxKind.StringLiteral
|
||||
? <StringLiteral>parseLiteralNode(/*internName*/ true)
|
||||
: parseType();
|
||||
return parseType();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -2369,6 +2385,8 @@ namespace ts {
|
||||
// If these are followed by a dot, then parse these out as a dotted type reference instead.
|
||||
const node = tryParse(parseKeywordAndNoDot);
|
||||
return node || parseTypeReferenceOrTypePredicate();
|
||||
case SyntaxKind.StringLiteral:
|
||||
return <StringLiteral>parseLiteralNode(/*internName*/ true);
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
return parseTokenNode<TypeNode>();
|
||||
@@ -2399,6 +2417,7 @@ namespace ts {
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
case SyntaxKind.NewKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return true;
|
||||
case SyntaxKind.OpenParenToken:
|
||||
// Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier,
|
||||
@@ -4568,7 +4587,6 @@ namespace ts {
|
||||
|
||||
function parseObjectBindingElement(): BindingElement {
|
||||
const node = <BindingElement>createNode(SyntaxKind.BindingElement);
|
||||
// TODO(andersh): Handle computed properties
|
||||
const tokenIsIdentifier = isIdentifier();
|
||||
const propertyName = parsePropertyName();
|
||||
if (tokenIsIdentifier && token !== SyntaxKind.ColonToken) {
|
||||
@@ -4576,7 +4594,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
node.propertyName = <Identifier>propertyName;
|
||||
node.propertyName = propertyName;
|
||||
node.name = parseIdentifierOrPattern();
|
||||
}
|
||||
node.initializer = parseBindingElementInitializer(/*inParameter*/ false);
|
||||
@@ -5505,7 +5523,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined);
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
|
||||
const jsDocTypeExpression = parseJSDocTypeExpression(start, length);
|
||||
const diagnostics = parseDiagnostics;
|
||||
clearState();
|
||||
@@ -5616,6 +5634,7 @@ namespace ts {
|
||||
return parseTokenNode<JSDocType>();
|
||||
}
|
||||
|
||||
// TODO (drosen): Parse string literal types in JSDoc as well.
|
||||
return parseJSDocTypeReference();
|
||||
}
|
||||
|
||||
@@ -5825,7 +5844,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined);
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
|
||||
const jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length);
|
||||
const diagnostics = parseDiagnostics;
|
||||
clearState();
|
||||
|
||||
+67
-44
@@ -53,13 +53,13 @@ namespace ts {
|
||||
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
const failedLookupLocations: string[] = [];
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
let resolvedFileName = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
|
||||
let resolvedFileName = loadNodeModuleFromFile(supportedJsExtensions, candidate, failedLookupLocations, host);
|
||||
|
||||
if (resolvedFileName) {
|
||||
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
|
||||
}
|
||||
|
||||
resolvedFileName = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
|
||||
resolvedFileName = loadNodeModuleFromDirectory(supportedJsExtensions, candidate, failedLookupLocations, host);
|
||||
return resolvedFileName
|
||||
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
@@ -69,8 +69,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
return forEach(moduleFileExtensions, tryLoad);
|
||||
function loadNodeModuleFromFile(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
return forEach(extensions, tryLoad);
|
||||
|
||||
function tryLoad(ext: string): string {
|
||||
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
@@ -84,7 +84,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function loadNodeModuleFromDirectory(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
|
||||
const packageJsonPath = combinePaths(candidate, "package.json");
|
||||
if (host.fileExists(packageJsonPath)) {
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (jsonContent.typings) {
|
||||
const result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
|
||||
const result = loadNodeModuleFromFile(extensions, normalizePath(combinePaths(candidate, jsonContent.typings)), failedLookupLocation, host);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace ts {
|
||||
failedLookupLocation.push(packageJsonPath);
|
||||
}
|
||||
|
||||
return loadNodeModuleFromFile(combinePaths(candidate, "index"), failedLookupLocation, host);
|
||||
return loadNodeModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocation, host);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
@@ -122,12 +122,12 @@ namespace ts {
|
||||
if (baseName !== "node_modules") {
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
let result = loadNodeModuleFromFile(candidate, failedLookupLocations, host);
|
||||
let result = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
|
||||
result = loadNodeModuleFromDirectory(candidate, failedLookupLocations, host);
|
||||
result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, host);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
}
|
||||
@@ -162,9 +162,10 @@ namespace ts {
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
let referencedSourceFile: string;
|
||||
const extensions = compilerOptions.allowNonTsExtensions ? supportedJsExtensions : supportedExtensions;
|
||||
while (true) {
|
||||
searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
referencedSourceFile = forEach(supportedExtensions, extension => {
|
||||
referencedSourceFile = forEach(extensions, extension => {
|
||||
if (extension === ".tsx" && !compilerOptions.jsx) {
|
||||
// resolve .tsx files only if jsx support is enabled
|
||||
// 'logical not' handles both undefined and None cases
|
||||
@@ -688,45 +689,60 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
|
||||
const isJavaScriptFile = isSourceFileJavaScript(file);
|
||||
|
||||
let imports: LiteralExpression[];
|
||||
for (const node of file.statements) {
|
||||
collect(node, /* allowRelativeModuleNames */ true);
|
||||
collect(node, /* allowRelativeModuleNames */ true, /* collectOnlyRequireCalls */ false);
|
||||
}
|
||||
|
||||
file.imports = imports || emptyArray;
|
||||
|
||||
function collect(node: Node, allowRelativeModuleNames: boolean): void {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
let moduleNameExpr = getExternalModuleName(node);
|
||||
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
|
||||
break;
|
||||
}
|
||||
if (!(<LiteralExpression>moduleNameExpr).text) {
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
if (allowRelativeModuleNames || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
|
||||
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
forEachChild((<ModuleDeclaration>node).body, node => {
|
||||
function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void {
|
||||
if (!collectOnlyRequireCalls) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
let moduleNameExpr = getExternalModuleName(node);
|
||||
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
|
||||
break;
|
||||
}
|
||||
if (!(<LiteralExpression>moduleNameExpr).text) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (allowRelativeModuleNames || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
|
||||
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// only through top - level external module names. Relative external module names are not permitted.
|
||||
collect(node, /* allowRelativeModuleNames */ false);
|
||||
});
|
||||
}
|
||||
break;
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
forEachChild((<ModuleDeclaration>node).body, node => {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// only through top - level external module names. Relative external module names are not permitted.
|
||||
collect(node, /* allowRelativeModuleNames */ false, collectOnlyRequireCalls);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isJavaScriptFile) {
|
||||
if (isRequireCall(node)) {
|
||||
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
|
||||
}
|
||||
else {
|
||||
forEachChild(node, node => collect(node, allowRelativeModuleNames, /* collectOnlyRequireCalls */ true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -833,7 +849,6 @@ namespace ts {
|
||||
processImportedModules(file, basePath);
|
||||
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
files.unshift(file);
|
||||
}
|
||||
else {
|
||||
@@ -923,6 +938,10 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
if (!commonPathComponents) { // Can happen when all input files are .d.ts files
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
return getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
}
|
||||
|
||||
@@ -1024,12 +1043,16 @@ namespace ts {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile && options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
|
||||
if (options.outDir || // there is --outDir specified
|
||||
options.sourceRoot || // there is --sourceRoot specified
|
||||
(options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated
|
||||
(!outFile || firstExternalModuleSourceFile !== undefined))) {
|
||||
options.mapRoot) { // there is --mapRoot specified
|
||||
|
||||
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
|
||||
// If a rootDir is specified and is valid use it as the commonSourceDirectory
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] {
|
||||
let result: CommentRange[];
|
||||
let collecting = trailing || pos === 0;
|
||||
while (true) {
|
||||
while (pos < text.length) {
|
||||
const ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
@@ -650,6 +650,8 @@ namespace ts {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] {
|
||||
@@ -741,7 +743,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function scanNumber(): number {
|
||||
function scanNumber(): string {
|
||||
const start = pos;
|
||||
while (isDigit(text.charCodeAt(pos))) pos++;
|
||||
if (text.charCodeAt(pos) === CharacterCodes.dot) {
|
||||
@@ -761,7 +763,7 @@ namespace ts {
|
||||
error(Diagnostics.Digit_expected);
|
||||
}
|
||||
}
|
||||
return +(text.substring(start, end));
|
||||
return "" + +(text.substring(start, end));
|
||||
}
|
||||
|
||||
function scanOctalDigits(): number {
|
||||
@@ -1229,7 +1231,7 @@ namespace ts {
|
||||
return pos++, token = SyntaxKind.MinusToken;
|
||||
case CharacterCodes.dot:
|
||||
if (isDigit(text.charCodeAt(pos + 1))) {
|
||||
tokenValue = "" + scanNumber();
|
||||
tokenValue = scanNumber();
|
||||
return token = SyntaxKind.NumericLiteral;
|
||||
}
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.dot && text.charCodeAt(pos + 2) === CharacterCodes.dot) {
|
||||
@@ -1343,7 +1345,7 @@ namespace ts {
|
||||
case CharacterCodes._7:
|
||||
case CharacterCodes._8:
|
||||
case CharacterCodes._9:
|
||||
tokenValue = "" + scanNumber();
|
||||
tokenValue = scanNumber();
|
||||
return token = SyntaxKind.NumericLiteral;
|
||||
case CharacterCodes.colon:
|
||||
return pos++, token = SyntaxKind.ColonToken;
|
||||
|
||||
@@ -346,9 +346,20 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!cachedConfigFileText) {
|
||||
const error = createCompilerDiagnostic(Diagnostics.File_0_not_found, configFileName);
|
||||
reportDiagnostics([error], /* compilerHost */ undefined);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = parseConfigFileTextToJson(configFileName, cachedConfigFileText);
|
||||
const configObject = result.config;
|
||||
if (!configObject) {
|
||||
reportDiagnostics([result.error], /* compilerHost */ undefined);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
const configParseResult = parseJsonConfigFileContent(configObject, sys, getDirectoryPath(configFileName));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors, /* compilerHost */ undefined);
|
||||
|
||||
+13
-6
@@ -491,6 +491,7 @@ namespace ts {
|
||||
|
||||
export type EntityName = Identifier | QualifiedName;
|
||||
|
||||
export type PropertyName = Identifier | LiteralExpression | ComputedPropertyName;
|
||||
export type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern;
|
||||
|
||||
export interface Declaration extends Node {
|
||||
@@ -543,7 +544,7 @@ namespace ts {
|
||||
|
||||
// SyntaxKind.BindingElement
|
||||
export interface BindingElement extends Declaration {
|
||||
propertyName?: Identifier; // Binding property name (in object binding pattern)
|
||||
propertyName?: PropertyName; // Binding property name (in object binding pattern)
|
||||
dotDotDotToken?: Node; // Present on rest binding element
|
||||
name: Identifier | BindingPattern; // Declared binding element name
|
||||
initializer?: Expression; // Optional initializer
|
||||
@@ -587,7 +588,7 @@ namespace ts {
|
||||
// SyntaxKind.ShorthandPropertyAssignment
|
||||
// SyntaxKind.EnumMember
|
||||
export interface VariableLikeDeclaration extends Declaration {
|
||||
propertyName?: Identifier;
|
||||
propertyName?: PropertyName;
|
||||
dotDotDotToken?: Node;
|
||||
name: DeclarationName;
|
||||
questionToken?: Node;
|
||||
@@ -701,7 +702,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Note that a StringLiteral AST node is both an Expression and a TypeNode. The latter is
|
||||
// because string literals can appear in the type annotation of a parameter node.
|
||||
// because string literals can appear in type annotations as well.
|
||||
export interface StringLiteral extends LiteralExpression, TypeNode {
|
||||
_stringLiteralBrand: any;
|
||||
}
|
||||
@@ -773,7 +774,8 @@ namespace ts {
|
||||
expression?: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends Expression {
|
||||
// Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files
|
||||
export interface BinaryExpression extends Expression, Declaration {
|
||||
left: Expression;
|
||||
operatorToken: Node;
|
||||
right: Expression;
|
||||
@@ -834,7 +836,7 @@ namespace ts {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
}
|
||||
|
||||
export interface PropertyAccessExpression extends MemberExpression {
|
||||
export interface PropertyAccessExpression extends MemberExpression, Declaration {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
@@ -1284,8 +1286,9 @@ namespace ts {
|
||||
|
||||
// The first node that causes this file to be an external module
|
||||
/* @internal */ externalModuleIndicator: Node;
|
||||
// The first node that causes this file to be a CommonJS module
|
||||
/* @internal */ commonJsModuleIndicator: Node;
|
||||
|
||||
/* @internal */ isDefaultLib: boolean;
|
||||
/* @internal */ identifiers: Map<string>;
|
||||
/* @internal */ nodeCount: number;
|
||||
/* @internal */ identifierCount: number;
|
||||
@@ -1622,6 +1625,7 @@ namespace ts {
|
||||
getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind;
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
isArgumentsLocalBinding(node: Identifier): boolean;
|
||||
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
@@ -1821,6 +1825,7 @@ namespace ts {
|
||||
ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type
|
||||
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
|
||||
ThisType = 0x02000000, // This type
|
||||
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@@ -1956,6 +1961,8 @@ namespace ts {
|
||||
target?: TypeParameter; // Instantiation target
|
||||
/* @internal */
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
/* @internal */
|
||||
resolvedApparentType: Type;
|
||||
}
|
||||
|
||||
export const enum SignatureKind {
|
||||
|
||||
+174
-77
@@ -1,4 +1,3 @@
|
||||
/// <reference path="binder.ts" />
|
||||
/// <reference path="sys.ts" />
|
||||
|
||||
/* @internal */
|
||||
@@ -362,6 +361,10 @@ namespace ts {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
export function isExternalOrCommonJsModule(file: SourceFile): boolean {
|
||||
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
||||
}
|
||||
|
||||
export function isDeclarationFile(file: SourceFile): boolean {
|
||||
return (file.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
@@ -421,18 +424,26 @@ namespace ts {
|
||||
return getLeadingCommentRanges(sourceFileOfNode.text, node.pos);
|
||||
}
|
||||
|
||||
export function getLeadingCommentRangesOfNodeFromText(node: Node, text: string) {
|
||||
return getLeadingCommentRanges(text, node.pos);
|
||||
}
|
||||
|
||||
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
|
||||
return getJsDocCommentsFromText(node, sourceFileOfNode.text);
|
||||
}
|
||||
|
||||
export function getJsDocCommentsFromText(node: Node, text: string) {
|
||||
const commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ?
|
||||
concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos),
|
||||
getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) :
|
||||
getLeadingCommentRangesOfNode(node, sourceFileOfNode);
|
||||
concatenate(getTrailingCommentRanges(text, node.pos),
|
||||
getLeadingCommentRanges(text, node.pos)) :
|
||||
getLeadingCommentRangesOfNodeFromText(node, text);
|
||||
return filter(commentRanges, isJsDocComment);
|
||||
|
||||
function isJsDocComment(comment: CommentRange) {
|
||||
// True if the comment starts with '/**' but not if it is '/**/'
|
||||
return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
sourceFileOfNode.text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
|
||||
sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
|
||||
return text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,6 +1059,57 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration && (<ImportEqualsDeclaration>node).moduleReference.kind !== SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
export function isSourceFileJavaScript(file: SourceFile): boolean {
|
||||
return isInJavaScriptFile(file);
|
||||
}
|
||||
|
||||
export function isInJavaScriptFile(node: Node): boolean {
|
||||
return node && !!(node.parserContextFlags & ParserContextFlags.JavaScriptFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is a CallExpression to the identifier 'require' with
|
||||
* exactly one string literal argument.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isRequireCall(expression: Node): expression is CallExpression {
|
||||
// of the form 'require("name")'
|
||||
return expression.kind === SyntaxKind.CallExpression &&
|
||||
(<CallExpression>expression).expression.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>(<CallExpression>expression).expression).text === "require" &&
|
||||
(<CallExpression>expression).arguments.length === 1 &&
|
||||
(<CallExpression>expression).arguments[0].kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is an assignment to a property on the identifier 'exports'.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isExportsPropertyAssignment(expression: Node): boolean {
|
||||
// of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary
|
||||
return isInJavaScriptFile(expression) &&
|
||||
(expression.kind === SyntaxKind.BinaryExpression) &&
|
||||
((<BinaryExpression>expression).operatorToken.kind === SyntaxKind.EqualsToken) &&
|
||||
((<BinaryExpression>expression).left.kind === SyntaxKind.PropertyAccessExpression) &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression.kind === SyntaxKind.Identifier) &&
|
||||
((<Identifier>((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression)).text === "exports");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is an assignment to the property access expression 'module.exports'.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isModuleExportsAssignment(expression: Node): boolean {
|
||||
// of the form 'module.exports = expr' where 'expr' is arbitrary
|
||||
return isInJavaScriptFile(expression) &&
|
||||
(expression.kind === SyntaxKind.BinaryExpression) &&
|
||||
((<BinaryExpression>expression).operatorToken.kind === SyntaxKind.EqualsToken) &&
|
||||
((<BinaryExpression>expression).left.kind === SyntaxKind.PropertyAccessExpression) &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression.kind === SyntaxKind.Identifier) &&
|
||||
((<Identifier>((<PropertyAccessExpression>(<BinaryExpression>expression).left).expression)).text === "module") &&
|
||||
((<PropertyAccessExpression>(<BinaryExpression>expression).left).name.text === "exports");
|
||||
}
|
||||
|
||||
export function getExternalModuleName(node: Node): Expression {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return (<ImportDeclaration>node).moduleSpecifier;
|
||||
@@ -1383,8 +1445,8 @@ namespace ts {
|
||||
export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult {
|
||||
const simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
const isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
if (simpleReferenceRegEx.test(comment)) {
|
||||
if (isNoDefaultLibRegEx.test(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
};
|
||||
@@ -1427,6 +1489,10 @@ namespace ts {
|
||||
return isFunctionLike(node) && (node.flags & NodeFlags.Async) !== 0 && !isAccessor(node);
|
||||
}
|
||||
|
||||
export function isStringOrNumericLiteral(kind: SyntaxKind): boolean {
|
||||
return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* A declaration has a dynamic name if both of the following are true:
|
||||
* 1. The declaration has a computed property name
|
||||
@@ -1435,9 +1501,13 @@ namespace ts {
|
||||
* Symbol.
|
||||
*/
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name &&
|
||||
declaration.name.kind === SyntaxKind.ComputedPropertyName &&
|
||||
!isWellKnownSymbolSyntactically((<ComputedPropertyName>declaration.name).expression);
|
||||
return declaration.name && isDynamicName(declaration.name);
|
||||
}
|
||||
|
||||
export function isDynamicName(name: DeclarationName): boolean {
|
||||
return name.kind === SyntaxKind.ComputedPropertyName &&
|
||||
!isStringOrNumericLiteral((<ComputedPropertyName>name).expression.kind) &&
|
||||
!isWellKnownSymbolSyntactically((<ComputedPropertyName>name).expression);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1652,6 +1722,7 @@ namespace ts {
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
|
||||
@@ -1689,7 +1760,7 @@ namespace ts {
|
||||
|
||||
export interface EmitTextWriter {
|
||||
write(s: string): void;
|
||||
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
|
||||
writeTextOfNode(text: string, node: Node): void;
|
||||
writeLine(): void;
|
||||
increaseIndent(): void;
|
||||
decreaseIndent(): void;
|
||||
@@ -1700,6 +1771,7 @@ namespace ts {
|
||||
getLine(): number;
|
||||
getColumn(): number;
|
||||
getIndent(): number;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
const indentStrings: string[] = ["", " "];
|
||||
@@ -1715,11 +1787,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createTextWriter(newLine: String): EmitTextWriter {
|
||||
let output = "";
|
||||
let indent = 0;
|
||||
let lineStart = true;
|
||||
let lineCount = 0;
|
||||
let linePos = 0;
|
||||
let output: string;
|
||||
let indent: number;
|
||||
let lineStart: boolean;
|
||||
let lineCount: number;
|
||||
let linePos: number;
|
||||
|
||||
function write(s: string) {
|
||||
if (s && s.length) {
|
||||
@@ -1731,6 +1803,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reset(): void {
|
||||
output = "";
|
||||
indent = 0;
|
||||
lineStart = true;
|
||||
lineCount = 0;
|
||||
linePos = 0;
|
||||
}
|
||||
|
||||
function rawWrite(s: string) {
|
||||
if (s !== undefined) {
|
||||
if (lineStart) {
|
||||
@@ -1760,10 +1840,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function writeTextOfNode(sourceFile: SourceFile, node: Node) {
|
||||
write(getSourceTextOfNodeFromSourceFile(sourceFile, node));
|
||||
function writeTextOfNode(text: string, node: Node) {
|
||||
write(getTextOfNodeFromSourceText(text, node));
|
||||
}
|
||||
|
||||
reset();
|
||||
|
||||
return {
|
||||
write,
|
||||
rawWrite,
|
||||
@@ -1777,9 +1859,19 @@ namespace ts {
|
||||
getLine: () => lineCount + 1,
|
||||
getColumn: () => lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1,
|
||||
getText: () => output,
|
||||
reset
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a local path to a path which is absolute to the base of the emit
|
||||
*/
|
||||
export function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string {
|
||||
const dir = host.getCurrentDirectory();
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(dir, fileName, dir, f => host.getCanonicalFileName(f), /*isAbsolutePathAnUrl*/ false);
|
||||
return removeFileExtension(relativePath);
|
||||
}
|
||||
|
||||
export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) {
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
let emitOutputFilePathWithoutExtension: string;
|
||||
@@ -1809,6 +1901,10 @@ namespace ts {
|
||||
return getLineAndCharacterOfPosition(currentSourceFile, pos).line;
|
||||
}
|
||||
|
||||
export function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number) {
|
||||
return computeLineAndCharacterOfPosition(lineMap, pos).line;
|
||||
}
|
||||
|
||||
export function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration {
|
||||
return forEach(node.members, member => {
|
||||
if (member.kind === SyntaxKind.Constructor && nodeIsPresent((<ConstructorDeclaration>member).body)) {
|
||||
@@ -1883,23 +1979,23 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) {
|
||||
export function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) {
|
||||
// If the leading comments start on different line than the start of node, write new line
|
||||
if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos &&
|
||||
getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) {
|
||||
getLineOfLocalPositionFromLineMap(lineMap, node.pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
|
||||
writer.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
export function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string,
|
||||
writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void) {
|
||||
export function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string,
|
||||
writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, comment: CommentRange, newLine: string) => void) {
|
||||
let emitLeadingSpace = !trailingSeparator;
|
||||
forEach(comments, comment => {
|
||||
if (emitLeadingSpace) {
|
||||
writer.write(" ");
|
||||
emitLeadingSpace = false;
|
||||
}
|
||||
writeComment(currentSourceFile, writer, comment, newLine);
|
||||
writeComment(text, lineMap, writer, comment, newLine);
|
||||
if (comment.hasTrailingNewLine) {
|
||||
writer.writeLine();
|
||||
}
|
||||
@@ -1917,8 +2013,8 @@ namespace ts {
|
||||
* Detached comment is a comment at the top of file or function body that is separated from
|
||||
* the next statement by space.
|
||||
*/
|
||||
export function emitDetachedComments(currentSourceFile: SourceFile, writer: EmitTextWriter,
|
||||
writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void,
|
||||
export function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter,
|
||||
writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, comment: CommentRange, newLine: string) => void,
|
||||
node: TextRange, newLine: string, removeComments: boolean) {
|
||||
let leadingComments: CommentRange[];
|
||||
let currentDetachedCommentInfo: {nodePos: number, detachedCommentEndPos: number};
|
||||
@@ -1929,12 +2025,12 @@ namespace ts {
|
||||
//
|
||||
// var x = 10;
|
||||
if (node.pos === 0) {
|
||||
leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment);
|
||||
leadingComments = filter(getLeadingCommentRanges(text, node.pos), isPinnedComment);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// removeComments is false, just get detached as normal and bypass the process to filter comment
|
||||
leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
leadingComments = getLeadingCommentRanges(text, node.pos);
|
||||
}
|
||||
|
||||
if (leadingComments) {
|
||||
@@ -1943,8 +2039,8 @@ namespace ts {
|
||||
|
||||
for (const comment of leadingComments) {
|
||||
if (lastComment) {
|
||||
const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end);
|
||||
const commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos);
|
||||
const lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
|
||||
const commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
|
||||
|
||||
if (commentLine >= lastCommentLine + 2) {
|
||||
// There was a blank line between the last comment and this comment. This
|
||||
@@ -1962,12 +2058,12 @@ namespace ts {
|
||||
// All comments look like they could have been part of the copyright header. Make
|
||||
// sure there is at least one blank line between it and the node. If not, it's not
|
||||
// a copyright header.
|
||||
const lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastOrUndefined(detachedComments).end);
|
||||
const nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
const lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastOrUndefined(detachedComments).end);
|
||||
const nodeLine = getLineOfLocalPositionFromLineMap(lineMap, skipTrivia(text, node.pos));
|
||||
if (nodeLine >= lastCommentLine + 2) {
|
||||
// Valid detachedComments
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
|
||||
emitComments(text, lineMap, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: lastOrUndefined(detachedComments).end };
|
||||
}
|
||||
}
|
||||
@@ -1976,25 +2072,26 @@ namespace ts {
|
||||
return currentDetachedCommentInfo;
|
||||
|
||||
function isPinnedComment(comment: CommentRange) {
|
||||
return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
return text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) {
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
const firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
const lineCount = getLineStarts(currentSourceFile).length;
|
||||
export function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, comment: CommentRange, newLine: string) {
|
||||
if (text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
const firstCommentLineAndCharacter = computeLineAndCharacterOfPosition(lineMap, comment.pos);
|
||||
const lineCount = lineMap.length;
|
||||
let firstCommentLineIndent: number;
|
||||
for (let pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
const nextLineStart = (currentLine + 1) === lineCount
|
||||
? currentSourceFile.text.length + 1
|
||||
: getStartPositionOfLine(currentLine + 1, currentSourceFile);
|
||||
? text.length + 1
|
||||
: lineMap[currentLine + 1];
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
if (firstCommentLineIndent === undefined) {
|
||||
firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos);
|
||||
firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], comment.pos);
|
||||
}
|
||||
|
||||
// These are number of spaces writer is going to write at current indent
|
||||
@@ -2014,7 +2111,7 @@ namespace ts {
|
||||
// More right indented comment */ --4 = 8 - 4 + 11
|
||||
// class c { }
|
||||
// }
|
||||
const spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
|
||||
const spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
|
||||
if (spacesToEmit > 0) {
|
||||
let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
|
||||
const indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
|
||||
@@ -2035,47 +2132,47 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Write the comment line text
|
||||
writeTrimmedCurrentLine(pos, nextLineStart);
|
||||
writeTrimmedCurrentLine(text, comment, writer, newLine, pos, nextLineStart);
|
||||
|
||||
pos = nextLineStart;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Single line comment of style //....
|
||||
writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
|
||||
writer.write(text.substring(comment.pos, comment.end));
|
||||
}
|
||||
}
|
||||
|
||||
function writeTrimmedCurrentLine(pos: number, nextLineStart: number) {
|
||||
const end = Math.min(comment.end, nextLineStart - 1);
|
||||
const currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, "");
|
||||
if (currentLineText) {
|
||||
// trimmed forward and ending spaces text
|
||||
writer.write(currentLineText);
|
||||
if (end !== comment.end) {
|
||||
writer.writeLine();
|
||||
}
|
||||
function writeTrimmedCurrentLine(text: string, comment: CommentRange, writer: EmitTextWriter, newLine: string, pos: number, nextLineStart: number) {
|
||||
const end = Math.min(comment.end, nextLineStart - 1);
|
||||
const currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
|
||||
if (currentLineText) {
|
||||
// trimmed forward and ending spaces text
|
||||
writer.write(currentLineText);
|
||||
if (end !== comment.end) {
|
||||
writer.writeLine();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Empty string - make sure we write empty line
|
||||
writer.writeLiteral(newLine);
|
||||
}
|
||||
}
|
||||
|
||||
function calculateIndent(text: string, pos: number, end: number) {
|
||||
let currentLineIndent = 0;
|
||||
for (; pos < end && isWhiteSpace(text.charCodeAt(pos)); pos++) {
|
||||
if (text.charCodeAt(pos) === CharacterCodes.tab) {
|
||||
// Tabs = TabSize = indent size and go to next tabStop
|
||||
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
|
||||
}
|
||||
else {
|
||||
// Empty string - make sure we write empty line
|
||||
writer.writeLiteral(newLine);
|
||||
// Single space
|
||||
currentLineIndent++;
|
||||
}
|
||||
}
|
||||
|
||||
function calculateIndent(pos: number, end: number) {
|
||||
let currentLineIndent = 0;
|
||||
for (; pos < end && isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
|
||||
if (currentSourceFile.text.charCodeAt(pos) === CharacterCodes.tab) {
|
||||
// Tabs = TabSize = indent size and go to next tabStop
|
||||
currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
|
||||
}
|
||||
else {
|
||||
// Single space
|
||||
currentLineIndent++;
|
||||
}
|
||||
}
|
||||
|
||||
return currentLineIndent;
|
||||
}
|
||||
return currentLineIndent;
|
||||
}
|
||||
|
||||
export function modifierToFlag(token: SyntaxKind): NodeFlags {
|
||||
@@ -2175,12 +2272,12 @@ namespace ts {
|
||||
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
|
||||
export function isJavaScript(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js");
|
||||
export function hasJavaScriptFileExtension(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js") || fileExtensionIs(fileName, ".jsx");
|
||||
}
|
||||
|
||||
export function isTsx(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx");
|
||||
export function allowsJsxExpressions(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-10
@@ -223,10 +223,22 @@ namespace FourSlash {
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
private addMatchedInputFile(referenceFilePath: string) {
|
||||
const inputFile = this.inputFiles[referenceFilePath];
|
||||
if (inputFile && !Harness.isLibraryFile(referenceFilePath)) {
|
||||
this.languageServiceAdapterHost.addScript(referenceFilePath, inputFile);
|
||||
private addMatchedInputFile(referenceFilePath: string, extensions: string[]) {
|
||||
const inputFiles = this.inputFiles;
|
||||
const languageServiceAdapterHost = this.languageServiceAdapterHost;
|
||||
if (!extensions) {
|
||||
tryAdd(referenceFilePath);
|
||||
}
|
||||
else {
|
||||
tryAdd(referenceFilePath) || ts.forEach(extensions, ext => tryAdd(referenceFilePath + ext));
|
||||
}
|
||||
|
||||
function tryAdd(path: string) {
|
||||
const inputFile = inputFiles[path];
|
||||
if (inputFile && !Harness.isLibraryFile(path)) {
|
||||
languageServiceAdapterHost.addScript(path, inputFile);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,15 +292,15 @@ namespace FourSlash {
|
||||
ts.forEach(referencedFiles, referenceFile => {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path
|
||||
const referenceFilePath = this.basePath + "/" + referenceFile.fileName;
|
||||
this.addMatchedInputFile(referenceFilePath);
|
||||
this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined);
|
||||
});
|
||||
|
||||
// Add import files into language-service host
|
||||
ts.forEach(importedFiles, importedFile => {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts"
|
||||
// so convert them before making appropriate comparison
|
||||
const importedFilePath = this.basePath + "/" + importedFile.fileName + ".ts";
|
||||
this.addMatchedInputFile(importedFilePath);
|
||||
const importedFilePath = this.basePath + "/" + importedFile.fileName;
|
||||
this.addMatchedInputFile(importedFilePath, compilationOptions.allowNonTsExtensions ? ts.supportedJsExtensions : ts.supportedExtensions);
|
||||
});
|
||||
|
||||
// Check if no-default-lib flag is false and if so add default library
|
||||
@@ -2257,15 +2269,15 @@ namespace FourSlash {
|
||||
const details = this.getCompletionEntryDetails(item.name);
|
||||
|
||||
if (documentation !== undefined) {
|
||||
assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation"));
|
||||
assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation for " + name));
|
||||
}
|
||||
if (text !== undefined) {
|
||||
assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text"));
|
||||
assert.equal(ts.displayPartsToString(details.displayParts), text, assertionMessage("completion item detail text for " + name));
|
||||
}
|
||||
}
|
||||
|
||||
if (kind !== undefined) {
|
||||
assert.equal(item.kind, kind, assertionMessage("completion item kind"));
|
||||
assert.equal(item.kind, kind, assertionMessage("completion item kind for " + name));
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -1169,7 +1169,7 @@ namespace Harness {
|
||||
}
|
||||
else if (isTS(file.unitName)) {
|
||||
const declFile = findResultCodeFile(file.unitName);
|
||||
if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) {
|
||||
if (declFile && !findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) {
|
||||
dtsFiles.push({ unitName: declFile.fileName, content: declFile.code });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace Harness.LanguageService {
|
||||
getHost() { return this.host; }
|
||||
getLanguageService(): ts.LanguageService { return ts.createLanguageService(this.host); }
|
||||
getClassifier(): ts.Classifier { return ts.createClassifier(); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { return ts.preProcessFile(fileContents, /* readImportFiles */ true, ts.hasJavaScriptFileExtension(fileName)); }
|
||||
}
|
||||
|
||||
/// Shim adapter
|
||||
|
||||
@@ -306,7 +306,10 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
const outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName));
|
||||
const file = findOutpuDtsFile(outputDtsFileName);
|
||||
if (file) {
|
||||
allInputFiles.unshift(file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts";
|
||||
@@ -346,7 +349,7 @@ class ProjectRunner extends RunnerBase {
|
||||
const inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
return { unitName: RunnerBase.removeFullPaths(sourceFile.fileName), content: sourceFile.text };
|
||||
});
|
||||
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
@@ -387,7 +390,7 @@ class ProjectRunner extends RunnerBase {
|
||||
return resolutionInfo;
|
||||
}
|
||||
|
||||
it(name + ": " + moduleNameToString(moduleKind) , () => {
|
||||
it(name + ": " + moduleNameToString(moduleKind), () => {
|
||||
// Compile using node
|
||||
compilerResult = batchCompilerProjectTestCase(moduleKind);
|
||||
});
|
||||
|
||||
@@ -371,6 +371,10 @@ namespace ts.server {
|
||||
openRefCount = 0;
|
||||
|
||||
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
|
||||
if (projectOptions && projectOptions.files) {
|
||||
// If files are listed explicitly, allow all extensions
|
||||
projectOptions.compilerOptions.allowNonTsExtensions = true;
|
||||
}
|
||||
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
|
||||
}
|
||||
|
||||
@@ -461,6 +465,7 @@ namespace ts.server {
|
||||
setProjectOptions(projectOptions: ProjectOptions) {
|
||||
this.projectOptions = projectOptions;
|
||||
if (projectOptions.compilerOptions) {
|
||||
projectOptions.compilerOptions.allowNonTsExtensions = true;
|
||||
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
|
||||
}
|
||||
}
|
||||
@@ -1316,7 +1321,9 @@ namespace ts.server {
|
||||
this.setCompilerOptions(opt);
|
||||
}
|
||||
else {
|
||||
this.setCompilerOptions(ts.getDefaultCompilerOptions());
|
||||
const defaultOpts = ts.getDefaultCompilerOptions();
|
||||
defaultOpts.allowNonTsExtensions = true;
|
||||
this.setCompilerOptions(defaultOpts);
|
||||
}
|
||||
this.languageService = ts.createLanguageService(this.host, this.documentRegistry);
|
||||
this.classifier = ts.createClassifier();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ts.formatting {
|
||||
constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]) {
|
||||
this.tokens = [];
|
||||
for (let token = from; token <= to; token++) {
|
||||
if (except.indexOf(token) < 0) {
|
||||
if (ts.indexOf(except, token) < 0) {
|
||||
this.tokens.push(token);
|
||||
}
|
||||
}
|
||||
@@ -123,4 +123,4 @@ namespace ts.formatting {
|
||||
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+312
-190
@@ -174,7 +174,7 @@ namespace ts {
|
||||
let jsDocCompletionEntries: CompletionEntry[];
|
||||
|
||||
function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject {
|
||||
let node = <NodeObject> new (getNodeConstructor(kind))(pos, end);
|
||||
let node = new NodeObject(kind, pos, end);
|
||||
node.flags = flags;
|
||||
node.parent = parent;
|
||||
return node;
|
||||
@@ -188,6 +188,14 @@ namespace ts {
|
||||
public parent: Node;
|
||||
private _children: Node[];
|
||||
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
this.kind = kind;
|
||||
this.pos = pos;
|
||||
this.end = end;
|
||||
this.flags = NodeFlags.None;
|
||||
this.parent = undefined;
|
||||
}
|
||||
|
||||
public getSourceFile(): SourceFile {
|
||||
return getSourceFileOfNode(this);
|
||||
}
|
||||
@@ -793,6 +801,7 @@ namespace ts {
|
||||
public isDefaultLib: boolean;
|
||||
public hasNoDefaultLib: boolean;
|
||||
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
public commonJsModuleIndicator: Node; // The first node that causes this file to be a CommonJS module
|
||||
public nodeCount: number;
|
||||
public identifierCount: number;
|
||||
public symbolCount: number;
|
||||
@@ -805,6 +814,10 @@ namespace ts {
|
||||
public imports: LiteralExpression[];
|
||||
private namedDeclarations: Map<Declaration[]>;
|
||||
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
super(kind, pos, end)
|
||||
}
|
||||
|
||||
public update(newText: string, textChangeRange: TextChangeRange): SourceFile {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
}
|
||||
@@ -1599,6 +1612,9 @@ namespace ts {
|
||||
public static typeAliasName = "type alias name";
|
||||
public static parameterName = "parameter name";
|
||||
public static docCommentTagName = "doc comment tag name";
|
||||
public static jsxOpenTagName = "jsx open tag name";
|
||||
public static jsxCloseTagName = "jsx close tag name";
|
||||
public static jsxSelfClosingTagName = "jsx self closing tag name";
|
||||
}
|
||||
|
||||
export const enum ClassificationType {
|
||||
@@ -1620,6 +1636,9 @@ namespace ts {
|
||||
typeAliasName = 16,
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
jsxOpenTagName = 19,
|
||||
jsxCloseTagName = 20,
|
||||
jsxSelfClosingTagName = 21,
|
||||
}
|
||||
|
||||
/// Language Service
|
||||
@@ -2112,7 +2131,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function preProcessFile(sourceText: string, readImportFiles = true): PreProcessedFileInfo {
|
||||
export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo {
|
||||
let referencedFiles: FileReference[] = [];
|
||||
let importedFiles: FileReference[] = [];
|
||||
let ambientExternalModules: string[];
|
||||
@@ -2150,9 +2169,225 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function processImport(): void {
|
||||
/**
|
||||
* Returns true if at least one token was consumed from the stream
|
||||
*/
|
||||
function tryConsumeDeclare(): boolean {
|
||||
let token = scanner.getToken();
|
||||
if (token === SyntaxKind.DeclareKeyword) {
|
||||
// declare module "mod"
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.ModuleKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
recordAmbientExternalModule();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if at least one token was consumed from the stream
|
||||
*/
|
||||
function tryConsumeImport(): boolean {
|
||||
let token = scanner.getToken();
|
||||
if (token === SyntaxKind.ImportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import "mod";
|
||||
recordModuleName();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import d from "mod";
|
||||
recordModuleName();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.EqualsToken) {
|
||||
if (tryConsumeRequireCall(/* skipCurrentToken */ true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.CommaToken) {
|
||||
// consume comma and keep going
|
||||
token = scanner.scan();
|
||||
}
|
||||
else {
|
||||
// unknown syntax
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
token = scanner.scan();
|
||||
// consume "{ a as B, c, d as D}" clauses
|
||||
// make sure that it stops on EOF
|
||||
while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) {
|
||||
token = scanner.scan();
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import {a as A} from "mod";
|
||||
// import d, {a, b as B} from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.AsteriskToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.AsKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import * as NS from "mod"
|
||||
// import d, * as NS from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryConsumeExport(): boolean {
|
||||
let token = scanner.getToken();
|
||||
if (token === SyntaxKind.ExportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
token = scanner.scan();
|
||||
// consume "{ a as B, c, d as D}" clauses
|
||||
// make sure it stops on EOF
|
||||
while (token !== SyntaxKind.CloseBraceToken && token !== SyntaxKind.EndOfFileToken) {
|
||||
token = scanner.scan();
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// export {a as A} from "mod";
|
||||
// export {a, b as B} from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.AsteriskToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// export * from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.ImportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.EqualsToken) {
|
||||
if (tryConsumeRequireCall(/* skipCurrentToken */ true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryConsumeRequireCall(skipCurrentToken: boolean): boolean {
|
||||
let token = skipCurrentToken ? scanner.scan() : scanner.getToken();
|
||||
if (token === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// require("mod");
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function tryConsumeDefine(): boolean {
|
||||
let token = scanner.getToken();
|
||||
if (token === SyntaxKind.Identifier && scanner.getTokenValue() === "define") {
|
||||
token = scanner.scan();
|
||||
if (token !== SyntaxKind.OpenParenToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// looks like define ("modname", ... - skip string literal and comma
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.CommaToken) {
|
||||
token = scanner.scan();
|
||||
}
|
||||
else {
|
||||
// unexpected token
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// should be start of dependency list
|
||||
if (token !== SyntaxKind.OpenBracketToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// skip open bracket
|
||||
token = scanner.scan();
|
||||
let i = 0;
|
||||
// scan until ']' or EOF
|
||||
while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) {
|
||||
// record string literals as module names
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
recordModuleName();
|
||||
i++;
|
||||
}
|
||||
|
||||
token = scanner.scan();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function processImports(): void {
|
||||
scanner.setText(sourceText);
|
||||
let token = scanner.scan();
|
||||
scanner.scan();
|
||||
// Look for:
|
||||
// import "mod";
|
||||
// import d from "mod"
|
||||
@@ -2164,157 +2399,30 @@ namespace ts {
|
||||
// export * from "mod"
|
||||
// export {a as b} from "mod"
|
||||
// export import i = require("mod")
|
||||
// (for JavaScript files) require("mod")
|
||||
|
||||
while (token !== SyntaxKind.EndOfFileToken) {
|
||||
if (token === SyntaxKind.DeclareKeyword) {
|
||||
// declare module "mod"
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.ModuleKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
recordAmbientExternalModule();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
if (scanner.getToken() === SyntaxKind.EndOfFileToken) {
|
||||
break;
|
||||
}
|
||||
else if (token === SyntaxKind.ImportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import "mod";
|
||||
recordModuleName();
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import d from "mod";
|
||||
recordModuleName();
|
||||
continue
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.EqualsToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import i = require("mod");
|
||||
recordModuleName();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.CommaToken) {
|
||||
// consume comma and keep going
|
||||
token = scanner.scan();
|
||||
}
|
||||
else {
|
||||
// unknown syntax
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
token = scanner.scan();
|
||||
// consume "{ a as B, c, d as D}" clauses
|
||||
while (token !== SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import {a as A} from "mod";
|
||||
// import d, {a, b as B} from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.AsteriskToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.AsKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// import * as NS from "mod"
|
||||
// import d, * as NS from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if at least one of alternative have moved scanner forward
|
||||
if (tryConsumeDeclare() ||
|
||||
tryConsumeImport() ||
|
||||
tryConsumeExport() ||
|
||||
(detectJavaScriptImports && (tryConsumeRequireCall(/* skipCurrentToken */ false) || tryConsumeDefine()))) {
|
||||
continue;
|
||||
}
|
||||
else if (token === SyntaxKind.ExportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenBraceToken) {
|
||||
token = scanner.scan();
|
||||
// consume "{ a as B, c, d as D}" clauses
|
||||
while (token !== SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// export {a as A} from "mod";
|
||||
// export {a, b as B} from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.AsteriskToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.FromKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// export * from "mod"
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (token === SyntaxKind.ImportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.Identifier || isKeyword(token)) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.EqualsToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
// export import i = require("mod");
|
||||
recordModuleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
scanner.scan();
|
||||
}
|
||||
token = scanner.scan();
|
||||
}
|
||||
|
||||
scanner.setText(undefined);
|
||||
}
|
||||
|
||||
if (readImportFiles) {
|
||||
processImport();
|
||||
processImports();
|
||||
}
|
||||
processTripleSlashDirectives();
|
||||
return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules };
|
||||
@@ -2739,8 +2847,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
|
||||
if (!sourceFile) {
|
||||
return false;
|
||||
}
|
||||
let path = sourceFile.path || toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName);
|
||||
return sourceFile && sourceFile.version === hostCache.getVersion(path);
|
||||
return sourceFile.version === hostCache.getVersion(path);
|
||||
}
|
||||
|
||||
function programUpToDate(): boolean {
|
||||
@@ -2803,7 +2914,7 @@ namespace ts {
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
if (isJavaScript(fileName)) {
|
||||
if (isSourceFileJavaScript(targetSourceFile)) {
|
||||
return getJavaScriptSemanticDiagnostics(targetSourceFile);
|
||||
}
|
||||
|
||||
@@ -3042,7 +3153,7 @@ namespace ts {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let syntacticStart = new Date().getTime();
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
let isJavaScriptFile = isJavaScript(fileName);
|
||||
let isJavaScriptFile = isSourceFileJavaScript(sourceFile);
|
||||
|
||||
let isJsDocTagName = false;
|
||||
|
||||
@@ -3814,7 +3925,10 @@ namespace ts {
|
||||
let existingName: string;
|
||||
|
||||
if (m.kind === SyntaxKind.BindingElement && (<BindingElement>m).propertyName) {
|
||||
existingName = (<BindingElement>m).propertyName.text;
|
||||
// include only identifiers in completion list
|
||||
if ((<BindingElement>m).propertyName.kind === SyntaxKind.Identifier) {
|
||||
existingName = (<Identifier>(<BindingElement>m).propertyName).text
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO(jfreeman): Account for computed property name
|
||||
@@ -3863,22 +3977,25 @@ namespace ts {
|
||||
|
||||
let { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData;
|
||||
|
||||
let entries: CompletionEntry[];
|
||||
if (isJsDocTagName) {
|
||||
// If the current position is a jsDoc tag name, only tag names should be provided for completion
|
||||
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() };
|
||||
}
|
||||
|
||||
if (isRightOfDot && isJavaScript(fileName)) {
|
||||
entries = getCompletionEntriesFromSymbols(symbols);
|
||||
addRange(entries, getJavaScriptCompletionEntries());
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
let entries: CompletionEntry[] = [];
|
||||
|
||||
if (isRightOfDot && isSourceFileJavaScript(sourceFile)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries);
|
||||
addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames));
|
||||
}
|
||||
else {
|
||||
if (!symbols || symbols.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
entries = getCompletionEntriesFromSymbols(symbols);
|
||||
getCompletionEntriesFromSymbols(symbols, entries);
|
||||
}
|
||||
|
||||
// Add keywords if this is not a member completion list
|
||||
@@ -3888,26 +4005,23 @@ namespace ts {
|
||||
|
||||
return { isMemberCompletion, isNewIdentifierLocation, entries };
|
||||
|
||||
function getJavaScriptCompletionEntries(): CompletionEntry[] {
|
||||
function getJavaScriptCompletionEntries(sourceFile: SourceFile, uniqueNames: Map<string>): CompletionEntry[] {
|
||||
let entries: CompletionEntry[] = [];
|
||||
let allNames: Map<string> = {};
|
||||
let target = program.getCompilerOptions().target;
|
||||
|
||||
for (let sourceFile of program.getSourceFiles()) {
|
||||
let nameTable = getNameTable(sourceFile);
|
||||
for (let name in nameTable) {
|
||||
if (!allNames[name]) {
|
||||
allNames[name] = name;
|
||||
let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true);
|
||||
if (displayName) {
|
||||
let entry = {
|
||||
name: displayName,
|
||||
kind: ScriptElementKind.warning,
|
||||
kindModifiers: "",
|
||||
sortText: "1"
|
||||
};
|
||||
entries.push(entry);
|
||||
}
|
||||
let nameTable = getNameTable(sourceFile);
|
||||
for (let name in nameTable) {
|
||||
if (!uniqueNames[name]) {
|
||||
uniqueNames[name] = name;
|
||||
let displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks:*/ true);
|
||||
if (displayName) {
|
||||
let entry = {
|
||||
name: displayName,
|
||||
kind: ScriptElementKind.warning,
|
||||
kindModifiers: "",
|
||||
sortText: "1"
|
||||
};
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3951,26 +4065,24 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[]): Map<string> {
|
||||
let start = new Date().getTime();
|
||||
let entries: CompletionEntry[] = [];
|
||||
|
||||
let uniqueNames: Map<string> = {};
|
||||
if (symbols) {
|
||||
let nameToSymbol: Map<Symbol> = {};
|
||||
for (let symbol of symbols) {
|
||||
let entry = createCompletionEntry(symbol, location);
|
||||
if (entry) {
|
||||
let id = escapeIdentifier(entry.name);
|
||||
if (!lookUp(nameToSymbol, id)) {
|
||||
if (!lookUp(uniqueNames, id)) {
|
||||
entries.push(entry);
|
||||
nameToSymbol[id] = symbol;
|
||||
uniqueNames[id] = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
|
||||
return entries;
|
||||
return uniqueNames;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6607,6 +6719,9 @@ namespace ts {
|
||||
case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName;
|
||||
case ClassificationType.parameterName: return ClassificationTypeNames.parameterName;
|
||||
case ClassificationType.docCommentTagName: return ClassificationTypeNames.docCommentTagName;
|
||||
case ClassificationType.jsxOpenTagName: return ClassificationTypeNames.jsxOpenTagName;
|
||||
case ClassificationType.jsxCloseTagName: return ClassificationTypeNames.jsxCloseTagName;
|
||||
case ClassificationType.jsxSelfClosingTagName: return ClassificationTypeNames.jsxSelfClosingTagName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6919,6 +7034,23 @@ namespace ts {
|
||||
}
|
||||
return;
|
||||
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
if ((<JsxOpeningElement>token.parent).tagName === token) {
|
||||
return ClassificationType.jsxOpenTagName;
|
||||
}
|
||||
return;
|
||||
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
if ((<JsxClosingElement>token.parent).tagName === token) {
|
||||
return ClassificationType.jsxCloseTagName;
|
||||
}
|
||||
return;
|
||||
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
if ((<JsxSelfClosingElement>token.parent).tagName === token) {
|
||||
return ClassificationType.jsxSelfClosingTagName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7970,18 +8102,8 @@ namespace ts {
|
||||
|
||||
function initializeServices() {
|
||||
objectAllocator = {
|
||||
getNodeConstructor: kind => {
|
||||
function Node(pos: number, end: number) {
|
||||
this.pos = pos;
|
||||
this.end = end;
|
||||
this.flags = NodeFlags.None;
|
||||
this.parent = undefined;
|
||||
}
|
||||
let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject();
|
||||
proto.kind = kind;
|
||||
Node.prototype = proto;
|
||||
return <any>Node;
|
||||
},
|
||||
getNodeConstructor: () => NodeObject,
|
||||
getSourceFileConstructor: () => SourceFileObject,
|
||||
getSymbolConstructor: () => SymbolObject,
|
||||
getTypeConstructor: () => TypeObject,
|
||||
getSignatureConstructor: () => SignatureObject,
|
||||
|
||||
@@ -956,7 +956,8 @@ namespace ts {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
() => {
|
||||
var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()));
|
||||
// for now treat files as JavaScript
|
||||
var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
|
||||
var convertResult = {
|
||||
referencedFiles: <IFileReference[]>[],
|
||||
importedFiles: <IFileReference[]>[],
|
||||
@@ -1032,7 +1033,7 @@ namespace ts {
|
||||
public createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim {
|
||||
try {
|
||||
if (this.documentRegistry === undefined) {
|
||||
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory());
|
||||
}
|
||||
var hostAdapter = new LanguageServiceShimHostAdapter(host);
|
||||
var languageService = createLanguageService(hostAdapter, this.documentRegistry);
|
||||
@@ -1068,7 +1069,7 @@ namespace ts {
|
||||
public close(): void {
|
||||
// Forget all the registered shims
|
||||
this._shims = [];
|
||||
this.documentRegistry = createDocumentRegistry();
|
||||
this.documentRegistry = undefined;
|
||||
}
|
||||
|
||||
public registerShim(shim: Shim): void {
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace ts.SignatureHelp {
|
||||
if (!candidates.length) {
|
||||
// We didn't have any sig help items produced by the TS compiler. If this is a JS
|
||||
// file, then see if we can figure out anything better.
|
||||
if (isJavaScript(sourceFile.fileName)) {
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
return createJavaScriptSignatureHelpItems(argumentInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
=== tests/cases/compiler/callSignatureFunctionOverload.ts ===
|
||||
var foo: {
|
||||
>foo : { (name: string): string; (name: 'order'): string; (name: 'content'): string; (name: 'done'): string; }
|
||||
>foo : { (name: string): string; (name: "order"): string; (name: "content"): string; (name: "done"): string; }
|
||||
|
||||
(name: string): string;
|
||||
>name : string
|
||||
|
||||
(name: 'order'): string;
|
||||
>name : 'order'
|
||||
>name : "order"
|
||||
|
||||
(name: 'content'): string;
|
||||
>name : 'content'
|
||||
>name : "content"
|
||||
|
||||
(name: 'done'): string;
|
||||
>name : 'done'
|
||||
>name : "done"
|
||||
}
|
||||
|
||||
var foo2: {
|
||||
>foo2 : { (name: string): string; (name: 'order'): string; (name: 'order'): string; (name: 'done'): string; }
|
||||
>foo2 : { (name: string): string; (name: "order"): string; (name: "order"): string; (name: "done"): string; }
|
||||
|
||||
(name: string): string;
|
||||
>name : string
|
||||
|
||||
(name: 'order'): string;
|
||||
>name : 'order'
|
||||
>name : "order"
|
||||
|
||||
(name: 'order'): string;
|
||||
>name : 'order'
|
||||
>name : "order"
|
||||
|
||||
(name: 'done'): string;
|
||||
>name : 'done'
|
||||
>name : "done"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1.ts(21,12): error TS2339: Property 'toExponential' does not exist on type 'string'.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/computedPropertiesInDestructuring1.ts (4 errors) ====
|
||||
// destructuring in variable declarations
|
||||
let foo = "bar";
|
||||
let {[foo]: bar} = {bar: "bar"};
|
||||
|
||||
let {["bar"]: bar2} = {bar: "bar"};
|
||||
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {bar: "bar"};
|
||||
|
||||
let [{[foo]: bar4}] = [{bar: "bar"}];
|
||||
let [{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
function f1({["bar"]: x}: { bar: number }) {}
|
||||
function f2({[foo]: x}: { bar: number }) {}
|
||||
function f3({[foo2()]: x}: { bar: number }) {}
|
||||
function f4([{[foo]: x}]: [{ bar: number }]) {}
|
||||
function f5([{[foo2()]: x}]: [{ bar: number }]) {}
|
||||
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
let [{[foo()]: bar6}] = [{bar: "bar"}];
|
||||
~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'toExponential' does not exist on type 'string'.
|
||||
|
||||
// destructuring assignment
|
||||
({[foo]: bar} = {bar: "bar"});
|
||||
|
||||
({["bar"]: bar2} = {bar: "bar"});
|
||||
|
||||
({[foo2()]: bar3} = {bar: "bar"});
|
||||
|
||||
[{[foo]: bar4}] = [{bar: "bar"}];
|
||||
[{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
[{[foo()]: bar4}] = [{bar: "bar"}];
|
||||
~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//// [computedPropertiesInDestructuring1.ts]
|
||||
// destructuring in variable declarations
|
||||
let foo = "bar";
|
||||
let {[foo]: bar} = {bar: "bar"};
|
||||
|
||||
let {["bar"]: bar2} = {bar: "bar"};
|
||||
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {bar: "bar"};
|
||||
|
||||
let [{[foo]: bar4}] = [{bar: "bar"}];
|
||||
let [{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
function f1({["bar"]: x}: { bar: number }) {}
|
||||
function f2({[foo]: x}: { bar: number }) {}
|
||||
function f3({[foo2()]: x}: { bar: number }) {}
|
||||
function f4([{[foo]: x}]: [{ bar: number }]) {}
|
||||
function f5([{[foo2()]: x}]: [{ bar: number }]) {}
|
||||
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
let [{[foo()]: bar6}] = [{bar: "bar"}];
|
||||
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
|
||||
|
||||
// destructuring assignment
|
||||
({[foo]: bar} = {bar: "bar"});
|
||||
|
||||
({["bar"]: bar2} = {bar: "bar"});
|
||||
|
||||
({[foo2()]: bar3} = {bar: "bar"});
|
||||
|
||||
[{[foo]: bar4}] = [{bar: "bar"}];
|
||||
[{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
[{[foo()]: bar4}] = [{bar: "bar"}];
|
||||
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
|
||||
|
||||
|
||||
|
||||
|
||||
//// [computedPropertiesInDestructuring1.js]
|
||||
// destructuring in variable declarations
|
||||
var foo = "bar";
|
||||
var _a = foo, bar = { bar: "bar" }[_a];
|
||||
var _b = "bar", bar2 = { bar: "bar" }[_b];
|
||||
var foo2 = function () { return "bar"; };
|
||||
var _c = foo2(), bar3 = { bar: "bar" }[_c];
|
||||
var _d = foo, bar4 = [{ bar: "bar" }][0][_d];
|
||||
var _e = foo2(), bar5 = [{ bar: "bar" }][0][_e];
|
||||
function f1(_a) {
|
||||
var _b = "bar", x = _a[_b];
|
||||
}
|
||||
function f2(_a) {
|
||||
var _b = foo, x = _a[_b];
|
||||
}
|
||||
function f3(_a) {
|
||||
var _b = foo2(), x = _a[_b];
|
||||
}
|
||||
function f4(_a) {
|
||||
var _b = foo, x = _a[0][_b];
|
||||
}
|
||||
function f5(_a) {
|
||||
var _b = foo2(), x = _a[0][_b];
|
||||
}
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
var _f = foo(), bar6 = [{ bar: "bar" }][0][_f];
|
||||
var _g = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_g];
|
||||
// destructuring assignment
|
||||
(_h = { bar: "bar" }, _j = foo, bar = _h[_j], _h);
|
||||
(_k = { bar: "bar" }, _l = "bar", bar2 = _k[_l], _k);
|
||||
(_m = { bar: "bar" }, _o = foo2(), bar3 = _m[_o], _m);
|
||||
_p = foo, bar4 = [{ bar: "bar" }][0][_p];
|
||||
_q = foo2(), bar5 = [{ bar: "bar" }][0][_q];
|
||||
_r = foo(), bar4 = [{ bar: "bar" }][0][_r];
|
||||
_s = (1 + {}), bar4 = [{ bar: "bar" }][0][_s];
|
||||
var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
||||
@@ -0,0 +1,51 @@
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(22,12): error TS2339: Property 'toExponential' does not exist on type 'string'.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts (4 errors) ====
|
||||
// destructuring in variable declarations
|
||||
let foo = "bar";
|
||||
let {[foo]: bar} = {bar: "bar"};
|
||||
|
||||
let {["bar"]: bar2} = {bar: "bar"};
|
||||
let {[11]: bar2_1} = {11: "bar"};
|
||||
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {bar: "bar"};
|
||||
|
||||
let [{[foo]: bar4}] = [{bar: "bar"}];
|
||||
let [{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
function f1({["bar"]: x}: { bar: number }) {}
|
||||
function f2({[foo]: x}: { bar: number }) {}
|
||||
function f3({[foo2()]: x}: { bar: number }) {}
|
||||
function f4([{[foo]: x}]: [{ bar: number }]) {}
|
||||
function f5([{[foo2()]: x}]: [{ bar: number }]) {}
|
||||
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
let [{[foo()]: bar6}] = [{bar: "bar"}];
|
||||
~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'toExponential' does not exist on type 'string'.
|
||||
|
||||
// destructuring assignment
|
||||
({[foo]: bar} = {bar: "bar"});
|
||||
|
||||
({["bar"]: bar2} = {bar: "bar"});
|
||||
|
||||
({[foo2()]: bar3} = {bar: "bar"});
|
||||
|
||||
[{[foo]: bar4}] = [{bar: "bar"}];
|
||||
[{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
[{[foo()]: bar4}] = [{bar: "bar"}];
|
||||
~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'.
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//// [computedPropertiesInDestructuring1_ES6.ts]
|
||||
// destructuring in variable declarations
|
||||
let foo = "bar";
|
||||
let {[foo]: bar} = {bar: "bar"};
|
||||
|
||||
let {["bar"]: bar2} = {bar: "bar"};
|
||||
let {[11]: bar2_1} = {11: "bar"};
|
||||
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {bar: "bar"};
|
||||
|
||||
let [{[foo]: bar4}] = [{bar: "bar"}];
|
||||
let [{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
function f1({["bar"]: x}: { bar: number }) {}
|
||||
function f2({[foo]: x}: { bar: number }) {}
|
||||
function f3({[foo2()]: x}: { bar: number }) {}
|
||||
function f4([{[foo]: x}]: [{ bar: number }]) {}
|
||||
function f5([{[foo2()]: x}]: [{ bar: number }]) {}
|
||||
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
let [{[foo()]: bar6}] = [{bar: "bar"}];
|
||||
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
|
||||
|
||||
// destructuring assignment
|
||||
({[foo]: bar} = {bar: "bar"});
|
||||
|
||||
({["bar"]: bar2} = {bar: "bar"});
|
||||
|
||||
({[foo2()]: bar3} = {bar: "bar"});
|
||||
|
||||
[{[foo]: bar4}] = [{bar: "bar"}];
|
||||
[{[foo2()]: bar5}] = [{bar: "bar"}];
|
||||
|
||||
[{[foo()]: bar4}] = [{bar: "bar"}];
|
||||
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
|
||||
|
||||
|
||||
//// [computedPropertiesInDestructuring1_ES6.js]
|
||||
// destructuring in variable declarations
|
||||
let foo = "bar";
|
||||
let { [foo]: bar } = { bar: "bar" };
|
||||
let { ["bar"]: bar2 } = { bar: "bar" };
|
||||
let { [11]: bar2_1 } = { 11: "bar" };
|
||||
let foo2 = () => "bar";
|
||||
let { [foo2()]: bar3 } = { bar: "bar" };
|
||||
let [{ [foo]: bar4 }] = [{ bar: "bar" }];
|
||||
let [{ [foo2()]: bar5 }] = [{ bar: "bar" }];
|
||||
function f1({ ["bar"]: x }) { }
|
||||
function f2({ [foo]: x }) { }
|
||||
function f3({ [foo2()]: x }) { }
|
||||
function f4([{ [foo]: x }]) { }
|
||||
function f5([{ [foo2()]: x }]) { }
|
||||
// report errors on type errors in computed properties used in destructuring
|
||||
let [{ [foo()]: bar6 }] = [{ bar: "bar" }];
|
||||
let [{ [foo.toExponential()]: bar7 }] = [{ bar: "bar" }];
|
||||
// destructuring assignment
|
||||
({ [foo]: bar } = { bar: "bar" });
|
||||
({ ["bar"]: bar2 } = { bar: "bar" });
|
||||
({ [foo2()]: bar3 } = { bar: "bar" });
|
||||
[{ [foo]: bar4 }] = [{ bar: "bar" }];
|
||||
[{ [foo2()]: bar5 }] = [{ bar: "bar" }];
|
||||
[{ [foo()]: bar4 }] = [{ bar: "bar" }];
|
||||
[{ [(1 + {})]: bar4 }] = [{ bar: "bar" }];
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [computedPropertiesInDestructuring2.ts]
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {};
|
||||
|
||||
//// [computedPropertiesInDestructuring2.js]
|
||||
var foo2 = function () { return "bar"; };
|
||||
var _a = foo2(), bar3 = {}[_a];
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/computedPropertiesInDestructuring2.ts ===
|
||||
let foo2 = () => "bar";
|
||||
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring2.ts, 0, 3))
|
||||
|
||||
let {[foo2()]: bar3} = {};
|
||||
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring2.ts, 0, 3))
|
||||
>bar3 : Symbol(bar3, Decl(computedPropertiesInDestructuring2.ts, 1, 5))
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/computedPropertiesInDestructuring2.ts ===
|
||||
let foo2 = () => "bar";
|
||||
>foo2 : () => string
|
||||
>() => "bar" : () => string
|
||||
>"bar" : string
|
||||
|
||||
let {[foo2()]: bar3} = {};
|
||||
>foo2() : string
|
||||
>foo2 : () => string
|
||||
>bar3 : any
|
||||
>{} : {}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [computedPropertiesInDestructuring2_ES6.ts]
|
||||
|
||||
let foo2 = () => "bar";
|
||||
let {[foo2()]: bar3} = {};
|
||||
|
||||
//// [computedPropertiesInDestructuring2_ES6.js]
|
||||
let foo2 = () => "bar";
|
||||
let { [foo2()]: bar3 } = {};
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/computedPropertiesInDestructuring2_ES6.ts ===
|
||||
|
||||
let foo2 = () => "bar";
|
||||
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring2_ES6.ts, 1, 3))
|
||||
|
||||
let {[foo2()]: bar3} = {};
|
||||
>foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring2_ES6.ts, 1, 3))
|
||||
>bar3 : Symbol(bar3, Decl(computedPropertiesInDestructuring2_ES6.ts, 2, 5))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/computedPropertiesInDestructuring2_ES6.ts ===
|
||||
|
||||
let foo2 = () => "bar";
|
||||
>foo2 : () => string
|
||||
>() => "bar" : () => string
|
||||
>"bar" : string
|
||||
|
||||
let {[foo2()]: bar3} = {};
|
||||
>foo2() : string
|
||||
>foo2 : () => string
|
||||
>bar3 : any
|
||||
>{} : {}
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : {}
|
||||
>v : { [0](): void; [""](): void; }
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [0](): void; [""](): void; }
|
||||
|
||||
[s]() { },
|
||||
>s : string
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : {}
|
||||
>v : { [0](): void; [""](): void; }
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : { [0](): void; [""](): void; }
|
||||
|
||||
[s]() { },
|
||||
>s : string
|
||||
|
||||
@@ -46,16 +46,8 @@ var v = (_a = {},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "", {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 0, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
,
|
||||
,
|
||||
Object.defineProperty(_a, a, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : {}
|
||||
>v : { [0]: number; [""]: any; }
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [0]: number; [""]: any; }
|
||||
|
||||
get [s]() { return 0; },
|
||||
>s : string
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : {}
|
||||
>v : { [0]: number; [""]: any; }
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : { [0]: number; [""]: any; }
|
||||
|
||||
get [s]() { return 0; },
|
||||
>s : string
|
||||
|
||||
@@ -3,15 +3,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (11 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (9 errors) ====
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
@@ -32,11 +30,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [""]: number;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[0]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[a]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
@@ -3,15 +3,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (11 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (9 errors) ====
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
@@ -32,11 +30,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [""]: number;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[0]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[a]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
@@ -48,16 +48,6 @@ var C = (function () {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "", {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, 0, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, a, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
|
||||
@@ -27,10 +27,6 @@ var C = (function () {
|
||||
Object.defineProperty(C.prototype, "get1", {
|
||||
// Computed properties
|
||||
get: function () { return new Foo; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "set1", {
|
||||
set: function (p) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
@@ -27,10 +27,6 @@ var C = (function () {
|
||||
Object.defineProperty(C.prototype, "get1", {
|
||||
// Computed properties
|
||||
get: function () { return new Foo; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "set1", {
|
||||
set: function (p) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8,5): error TS2393: Duplicate function implementation.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(9,5): error TS2393: Duplicate function implementation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts (3 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
@@ -10,7 +12,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES5.ts(8,
|
||||
|
||||
// Computed properties
|
||||
[""]() { return new Foo }
|
||||
~~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
|
||||
[""]() { return new Foo2 }
|
||||
~~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8,5): error TS2393: Duplicate function implementation.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8,5): error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(9,5): error TS2393: Duplicate function implementation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts (3 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
@@ -10,7 +12,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames40_ES6.ts(8,
|
||||
|
||||
// Computed properties
|
||||
[""]() { return new Foo }
|
||||
~~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2411: Property '[""]' of type '() => Foo' is not assignable to string index type '() => Foo2'.
|
||||
[""]() { return new Foo2 }
|
||||
~~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts (1 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
@@ -11,8 +10,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES5.ts(8,
|
||||
|
||||
// Computed properties
|
||||
[""]: Foo;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,5): error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts (1 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
@@ -11,8 +10,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames42_ES6.ts(8,
|
||||
|
||||
// Computed properties
|
||||
[""]: Foo;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2411: Property '[""]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
}
|
||||
@@ -41,10 +41,6 @@ var D = (function (_super) {
|
||||
Object.defineProperty(D.prototype, "get1", {
|
||||
// Computed properties
|
||||
get: function () { return new Foo; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(D.prototype, "set1", {
|
||||
set: function (p) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts (2 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
class C {
|
||||
get ["get1"]() { return new Foo }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts (2 errors) ====
|
||||
class Foo { x }
|
||||
class Foo2 { x; y }
|
||||
|
||||
class C {
|
||||
get ["get1"]() { return new Foo }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'.
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : {}
|
||||
>v : { [0]: number; [""]: number; }
|
||||
>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [0]: number; [""]: number; }
|
||||
|
||||
[s]: 0,
|
||||
>s : string
|
||||
|
||||
@@ -9,8 +9,8 @@ var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : {}
|
||||
>v : { [0]: number; [""]: number; }
|
||||
>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [<any>true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [0]: number; [""]: number; }
|
||||
|
||||
[s]: 0,
|
||||
>s : string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap2_ES5.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ ["hello"]() { debugger; }} : {}
|
||||
>v : { ["hello"](): void; }
|
||||
>{ ["hello"]() { debugger; }} : { ["hello"](): void; }
|
||||
|
||||
["hello"]() {
|
||||
>"hello" : string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap2_ES6.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ ["hello"]() { debugger; }} : {}
|
||||
>v : { ["hello"](): void; }
|
||||
>{ ["hello"]() { debugger; }} : { ["hello"](): void; }
|
||||
|
||||
["hello"]() {
|
||||
>"hello" : string
|
||||
|
||||
@@ -19,27 +19,27 @@ class Derived3 extends Base { biz() { } }
|
||||
>biz : () => void
|
||||
|
||||
function foo(tagName: 'canvas'): Derived1;
|
||||
>foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; }
|
||||
>tagName : 'canvas'
|
||||
>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; }
|
||||
>tagName : "canvas"
|
||||
>Derived1 : Derived1
|
||||
|
||||
function foo(tagName: 'div'): Derived2;
|
||||
>foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; }
|
||||
>tagName : 'div'
|
||||
>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; }
|
||||
>tagName : "div"
|
||||
>Derived2 : Derived2
|
||||
|
||||
function foo(tagName: 'span'): Derived3;
|
||||
>foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; }
|
||||
>tagName : 'span'
|
||||
>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; }
|
||||
>tagName : "span"
|
||||
>Derived3 : Derived3
|
||||
|
||||
function foo(tagName: string): Base;
|
||||
>foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; }
|
||||
>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; }
|
||||
>tagName : string
|
||||
>Base : Base
|
||||
|
||||
function foo(tagName: any): Base {
|
||||
>foo : { (tagName: 'canvas'): Derived1; (tagName: 'div'): Derived2; (tagName: 'span'): Derived3; (tagName: string): Base; }
|
||||
>foo : { (tagName: "canvas"): Derived1; (tagName: "div"): Derived2; (tagName: "span"): Derived3; (tagName: string): Base; }
|
||||
>tagName : any
|
||||
>Base : Base
|
||||
|
||||
|
||||
@@ -10,16 +10,16 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname1"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname2"]() {
|
||||
return "";
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
set ["computedname3"](x: any) {
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
set ["computedname4"](y: string) {
|
||||
}
|
||||
|
||||
set foo(a: string) { }
|
||||
@@ -38,15 +38,15 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname1"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname2"]() {
|
||||
return "";
|
||||
}
|
||||
set ["computedname"](x) {
|
||||
set ["computedname3"](x) {
|
||||
}
|
||||
set ["computedname"](y) {
|
||||
set ["computedname4"](y) {
|
||||
}
|
||||
set foo(a) { }
|
||||
static set bar(b) { }
|
||||
|
||||
@@ -21,18 +21,18 @@ class C {
|
||||
static get ["computedname"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname1"]() {
|
||||
return "";
|
||||
}
|
||||
get ["computedname"]() {
|
||||
get ["computedname2"]() {
|
||||
return "";
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
>x : Symbol(x, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 18, 25))
|
||||
set ["computedname3"](x: any) {
|
||||
>x : Symbol(x, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 18, 26))
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
>y : Symbol(y, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 20, 25))
|
||||
set ["computedname4"](y: string) {
|
||||
>y : Symbol(y, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 20, 26))
|
||||
}
|
||||
|
||||
set foo(a: string) { }
|
||||
|
||||
@@ -25,25 +25,25 @@ class C {
|
||||
return "";
|
||||
>"" : string
|
||||
}
|
||||
get ["computedname"]() {
|
||||
>"computedname" : string
|
||||
get ["computedname1"]() {
|
||||
>"computedname1" : string
|
||||
|
||||
return "";
|
||||
>"" : string
|
||||
}
|
||||
get ["computedname"]() {
|
||||
>"computedname" : string
|
||||
get ["computedname2"]() {
|
||||
>"computedname2" : string
|
||||
|
||||
return "";
|
||||
>"" : string
|
||||
}
|
||||
|
||||
set ["computedname"](x: any) {
|
||||
>"computedname" : string
|
||||
set ["computedname3"](x: any) {
|
||||
>"computedname3" : string
|
||||
>x : any
|
||||
}
|
||||
set ["computedname"](y: string) {
|
||||
>"computedname" : string
|
||||
set ["computedname4"](y: string) {
|
||||
>"computedname4" : string
|
||||
>y : string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
class D {
|
||||
_bar: string;
|
||||
foo() { }
|
||||
["computedName"]() { }
|
||||
["computedName"](a: string) { }
|
||||
["computedName"](a: string): number { return 1; }
|
||||
["computedName1"]() { }
|
||||
["computedName2"](a: string) { }
|
||||
["computedName3"](a: string): number { return 1; }
|
||||
bar(): string {
|
||||
return this._bar;
|
||||
}
|
||||
baz(a: any, x: string): string {
|
||||
return "HELLO";
|
||||
}
|
||||
static ["computedname"]() { }
|
||||
static ["computedname"](a: string) { }
|
||||
static ["computedname"](a: string): boolean { return true; }
|
||||
static ["computedname4"]() { }
|
||||
static ["computedname5"](a: string) { }
|
||||
static ["computedname6"](a: string): boolean { return true; }
|
||||
static staticMethod() {
|
||||
var x = 1 + 2;
|
||||
return x
|
||||
@@ -25,18 +25,18 @@ class D {
|
||||
//// [emitClassDeclarationWithMethodInES6.js]
|
||||
class D {
|
||||
foo() { }
|
||||
["computedName"]() { }
|
||||
["computedName"](a) { }
|
||||
["computedName"](a) { return 1; }
|
||||
["computedName1"]() { }
|
||||
["computedName2"](a) { }
|
||||
["computedName3"](a) { return 1; }
|
||||
bar() {
|
||||
return this._bar;
|
||||
}
|
||||
baz(a, x) {
|
||||
return "HELLO";
|
||||
}
|
||||
static ["computedname"]() { }
|
||||
static ["computedname"](a) { }
|
||||
static ["computedname"](a) { return true; }
|
||||
static ["computedname4"]() { }
|
||||
static ["computedname5"](a) { }
|
||||
static ["computedname6"](a) { return true; }
|
||||
static staticMethod() {
|
||||
var x = 1 + 2;
|
||||
return x;
|
||||
|
||||
@@ -8,15 +8,15 @@ class D {
|
||||
foo() { }
|
||||
>foo : Symbol(foo, Decl(emitClassDeclarationWithMethodInES6.ts, 1, 17))
|
||||
|
||||
["computedName"]() { }
|
||||
["computedName"](a: string) { }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 4, 21))
|
||||
["computedName1"]() { }
|
||||
["computedName2"](a: string) { }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 4, 22))
|
||||
|
||||
["computedName"](a: string): number { return 1; }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 21))
|
||||
["computedName3"](a: string): number { return 1; }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 22))
|
||||
|
||||
bar(): string {
|
||||
>bar : Symbol(bar, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 53))
|
||||
>bar : Symbol(bar, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 54))
|
||||
|
||||
return this._bar;
|
||||
>this._bar : Symbol(_bar, Decl(emitClassDeclarationWithMethodInES6.ts, 0, 9))
|
||||
@@ -30,15 +30,15 @@ class D {
|
||||
|
||||
return "HELLO";
|
||||
}
|
||||
static ["computedname"]() { }
|
||||
static ["computedname"](a: string) { }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 13, 28))
|
||||
static ["computedname4"]() { }
|
||||
static ["computedname5"](a: string) { }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 13, 29))
|
||||
|
||||
static ["computedname"](a: string): boolean { return true; }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 28))
|
||||
static ["computedname6"](a: string): boolean { return true; }
|
||||
>a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 29))
|
||||
|
||||
static staticMethod() {
|
||||
>staticMethod : Symbol(D.staticMethod, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 64))
|
||||
>staticMethod : Symbol(D.staticMethod, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 65))
|
||||
|
||||
var x = 1 + 2;
|
||||
>x : Symbol(x, Decl(emitClassDeclarationWithMethodInES6.ts, 16, 11))
|
||||
|
||||
@@ -8,15 +8,15 @@ class D {
|
||||
foo() { }
|
||||
>foo : () => void
|
||||
|
||||
["computedName"]() { }
|
||||
>"computedName" : string
|
||||
["computedName1"]() { }
|
||||
>"computedName1" : string
|
||||
|
||||
["computedName"](a: string) { }
|
||||
>"computedName" : string
|
||||
["computedName2"](a: string) { }
|
||||
>"computedName2" : string
|
||||
>a : string
|
||||
|
||||
["computedName"](a: string): number { return 1; }
|
||||
>"computedName" : string
|
||||
["computedName3"](a: string): number { return 1; }
|
||||
>"computedName3" : string
|
||||
>a : string
|
||||
>1 : number
|
||||
|
||||
@@ -36,15 +36,15 @@ class D {
|
||||
return "HELLO";
|
||||
>"HELLO" : string
|
||||
}
|
||||
static ["computedname"]() { }
|
||||
>"computedname" : string
|
||||
static ["computedname4"]() { }
|
||||
>"computedname4" : string
|
||||
|
||||
static ["computedname"](a: string) { }
|
||||
>"computedname" : string
|
||||
static ["computedname5"](a: string) { }
|
||||
>"computedname5" : string
|
||||
>a : string
|
||||
|
||||
static ["computedname"](a: string): boolean { return true; }
|
||||
>"computedname" : string
|
||||
static ["computedname6"](a: string): boolean { return true; }
|
||||
>"computedname6" : string
|
||||
>a : string
|
||||
>true : boolean
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; on
|
||||
Types of property 'oneI' are incompatible.
|
||||
Type 'this' is not assignable to type 'I'.
|
||||
Type 'C' is not assignable to type 'I'.
|
||||
Property 'alsoWorks' is missing in type 'C'.
|
||||
tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: this; }' nor type 'R' is assignable to the other.
|
||||
Property 'anything' is missing in type '{ oneI: this; }'.
|
||||
|
||||
@@ -38,6 +39,7 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: this;
|
||||
!!! error TS2322: Types of property 'oneI' are incompatible.
|
||||
!!! error TS2322: Type 'this' is not assignable to type 'I'.
|
||||
!!! error TS2322: Type 'C' is not assignable to type 'I'.
|
||||
!!! error TS2322: Property 'alsoWorks' is missing in type 'C'.
|
||||
}
|
||||
|
||||
worksToo():R {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
//// [genericClassExpressionInFunction.ts]
|
||||
class A<T> {
|
||||
genericVar: T
|
||||
}
|
||||
function B1<U>() {
|
||||
// class expression can use T
|
||||
return class extends A<U> { }
|
||||
}
|
||||
class B2<V> {
|
||||
anon = class extends A<V> { }
|
||||
}
|
||||
function B3<W>() {
|
||||
return class Inner<TInner> extends A<W> { }
|
||||
}
|
||||
// extends can call B
|
||||
class K extends B1<number>() {
|
||||
namae: string;
|
||||
}
|
||||
class C extends (new B2<number>().anon) {
|
||||
name: string;
|
||||
}
|
||||
let b3Number = B3<number>();
|
||||
class S extends b3Number<string> {
|
||||
nom: string;
|
||||
}
|
||||
var c = new C();
|
||||
var k = new K();
|
||||
var s = new S();
|
||||
c.genericVar = 12;
|
||||
k.genericVar = 12;
|
||||
s.genericVar = 12;
|
||||
|
||||
|
||||
//// [genericClassExpressionInFunction.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
function B1() {
|
||||
// class expression can use T
|
||||
return (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return class_1;
|
||||
})(A);
|
||||
}
|
||||
var B2 = (function () {
|
||||
function B2() {
|
||||
this.anon = (function (_super) {
|
||||
__extends(class_2, _super);
|
||||
function class_2() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return class_2;
|
||||
})(A);
|
||||
}
|
||||
return B2;
|
||||
})();
|
||||
function B3() {
|
||||
return (function (_super) {
|
||||
__extends(Inner, _super);
|
||||
function Inner() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return Inner;
|
||||
})(A);
|
||||
}
|
||||
// extends can call B
|
||||
var K = (function (_super) {
|
||||
__extends(K, _super);
|
||||
function K() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return K;
|
||||
})(B1());
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
})((new B2().anon));
|
||||
var b3Number = B3();
|
||||
var S = (function (_super) {
|
||||
__extends(S, _super);
|
||||
function S() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return S;
|
||||
})(b3Number);
|
||||
var c = new C();
|
||||
var k = new K();
|
||||
var s = new S();
|
||||
c.genericVar = 12;
|
||||
k.genericVar = 12;
|
||||
s.genericVar = 12;
|
||||
@@ -0,0 +1,92 @@
|
||||
=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts ===
|
||||
class A<T> {
|
||||
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8))
|
||||
|
||||
genericVar: T
|
||||
>genericVar : Symbol(genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
>T : Symbol(T, Decl(genericClassExpressionInFunction.ts, 0, 8))
|
||||
}
|
||||
function B1<U>() {
|
||||
>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1))
|
||||
>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12))
|
||||
|
||||
// class expression can use T
|
||||
return class extends A<U> { }
|
||||
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(genericClassExpressionInFunction.ts, 3, 12))
|
||||
}
|
||||
class B2<V> {
|
||||
>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1))
|
||||
>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9))
|
||||
|
||||
anon = class extends A<V> { }
|
||||
>anon : Symbol(anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
|
||||
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
|
||||
>V : Symbol(V, Decl(genericClassExpressionInFunction.ts, 7, 9))
|
||||
}
|
||||
function B3<W>() {
|
||||
>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1))
|
||||
>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12))
|
||||
|
||||
return class Inner<TInner> extends A<W> { }
|
||||
>Inner : Symbol(Inner, Decl(genericClassExpressionInFunction.ts, 11, 10))
|
||||
>TInner : Symbol(TInner, Decl(genericClassExpressionInFunction.ts, 11, 23))
|
||||
>A : Symbol(A, Decl(genericClassExpressionInFunction.ts, 0, 0))
|
||||
>W : Symbol(W, Decl(genericClassExpressionInFunction.ts, 10, 12))
|
||||
}
|
||||
// extends can call B
|
||||
class K extends B1<number>() {
|
||||
>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1))
|
||||
>B1 : Symbol(B1, Decl(genericClassExpressionInFunction.ts, 2, 1))
|
||||
|
||||
namae: string;
|
||||
>namae : Symbol(namae, Decl(genericClassExpressionInFunction.ts, 14, 30))
|
||||
}
|
||||
class C extends (new B2<number>().anon) {
|
||||
>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1))
|
||||
>new B2<number>().anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
|
||||
>B2 : Symbol(B2, Decl(genericClassExpressionInFunction.ts, 6, 1))
|
||||
>anon : Symbol(B2.anon, Decl(genericClassExpressionInFunction.ts, 7, 13))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(name, Decl(genericClassExpressionInFunction.ts, 17, 41))
|
||||
}
|
||||
let b3Number = B3<number>();
|
||||
>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3))
|
||||
>B3 : Symbol(B3, Decl(genericClassExpressionInFunction.ts, 9, 1))
|
||||
|
||||
class S extends b3Number<string> {
|
||||
>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28))
|
||||
>b3Number : Symbol(b3Number, Decl(genericClassExpressionInFunction.ts, 20, 3))
|
||||
|
||||
nom: string;
|
||||
>nom : Symbol(nom, Decl(genericClassExpressionInFunction.ts, 21, 34))
|
||||
}
|
||||
var c = new C();
|
||||
>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3))
|
||||
>C : Symbol(C, Decl(genericClassExpressionInFunction.ts, 16, 1))
|
||||
|
||||
var k = new K();
|
||||
>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3))
|
||||
>K : Symbol(K, Decl(genericClassExpressionInFunction.ts, 12, 1))
|
||||
|
||||
var s = new S();
|
||||
>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3))
|
||||
>S : Symbol(S, Decl(genericClassExpressionInFunction.ts, 20, 28))
|
||||
|
||||
c.genericVar = 12;
|
||||
>c.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
>c : Symbol(c, Decl(genericClassExpressionInFunction.ts, 24, 3))
|
||||
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
|
||||
k.genericVar = 12;
|
||||
>k.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
>k : Symbol(k, Decl(genericClassExpressionInFunction.ts, 25, 3))
|
||||
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
|
||||
s.genericVar = 12;
|
||||
>s.genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
>s : Symbol(s, Decl(genericClassExpressionInFunction.ts, 26, 3))
|
||||
>genericVar : Symbol(A.genericVar, Decl(genericClassExpressionInFunction.ts, 0, 12))
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
=== tests/cases/conformance/classes/classExpressions/genericClassExpressionInFunction.ts ===
|
||||
class A<T> {
|
||||
>A : A<T>
|
||||
>T : T
|
||||
|
||||
genericVar: T
|
||||
>genericVar : T
|
||||
>T : T
|
||||
}
|
||||
function B1<U>() {
|
||||
>B1 : <U>() => typeof (Anonymous class)
|
||||
>U : U
|
||||
|
||||
// class expression can use T
|
||||
return class extends A<U> { }
|
||||
>class extends A<U> { } : typeof (Anonymous class)
|
||||
>A : A<U>
|
||||
>U : U
|
||||
}
|
||||
class B2<V> {
|
||||
>B2 : B2<V>
|
||||
>V : V
|
||||
|
||||
anon = class extends A<V> { }
|
||||
>anon : typeof (Anonymous class)
|
||||
>class extends A<V> { } : typeof (Anonymous class)
|
||||
>A : A<V>
|
||||
>V : V
|
||||
}
|
||||
function B3<W>() {
|
||||
>B3 : <W>() => typeof Inner
|
||||
>W : W
|
||||
|
||||
return class Inner<TInner> extends A<W> { }
|
||||
>class Inner<TInner> extends A<W> { } : typeof Inner
|
||||
>Inner : typeof Inner
|
||||
>TInner : TInner
|
||||
>A : A<W>
|
||||
>W : W
|
||||
}
|
||||
// extends can call B
|
||||
class K extends B1<number>() {
|
||||
>K : K
|
||||
>B1<number>() : B1<number>.(Anonymous class)
|
||||
>B1 : <U>() => typeof (Anonymous class)
|
||||
|
||||
namae: string;
|
||||
>namae : string
|
||||
}
|
||||
class C extends (new B2<number>().anon) {
|
||||
>C : C
|
||||
>(new B2<number>().anon) : B2<number>.(Anonymous class)
|
||||
>new B2<number>().anon : typeof (Anonymous class)
|
||||
>new B2<number>() : B2<number>
|
||||
>B2 : typeof B2
|
||||
>anon : typeof (Anonymous class)
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
}
|
||||
let b3Number = B3<number>();
|
||||
>b3Number : typeof Inner
|
||||
>B3<number>() : typeof Inner
|
||||
>B3 : <W>() => typeof Inner
|
||||
|
||||
class S extends b3Number<string> {
|
||||
>S : S
|
||||
>b3Number : B3<number>.Inner<string>
|
||||
|
||||
nom: string;
|
||||
>nom : string
|
||||
}
|
||||
var c = new C();
|
||||
>c : C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
var k = new K();
|
||||
>k : K
|
||||
>new K() : K
|
||||
>K : typeof K
|
||||
|
||||
var s = new S();
|
||||
>s : S
|
||||
>new S() : S
|
||||
>S : typeof S
|
||||
|
||||
c.genericVar = 12;
|
||||
>c.genericVar = 12 : number
|
||||
>c.genericVar : number
|
||||
>c : C
|
||||
>genericVar : number
|
||||
>12 : number
|
||||
|
||||
k.genericVar = 12;
|
||||
>k.genericVar = 12 : number
|
||||
>k.genericVar : number
|
||||
>k : K
|
||||
>genericVar : number
|
||||
>12 : number
|
||||
|
||||
s.genericVar = 12;
|
||||
>s.genericVar = 12 : number
|
||||
>s.genericVar : number
|
||||
>s : S
|
||||
>genericVar : number
|
||||
>12 : number
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitSkipped: false
|
||||
FileName : declSingleFile.js.map
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAAA;IAGAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAAA;IAGAC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -8,4 +8,4 @@ var M = (function () {
|
||||
}
|
||||
return M;
|
||||
})();
|
||||
//# sourceMappingURL=mapRootDir/declSingleFile.js.map
|
||||
//# sourceMappingURL=tests/cases/fourslash/mapRootDir/declSingleFile.js.map
|
||||
|
||||
@@ -11,7 +11,7 @@ interface B extends A {
|
||||
>A : A
|
||||
|
||||
(key:'foo'):string;
|
||||
>key : 'foo'
|
||||
>key : "foo"
|
||||
}
|
||||
|
||||
var b:B;
|
||||
@@ -24,7 +24,7 @@ b('foo').charAt(0);
|
||||
>b('foo').charAt : (pos: number) => string
|
||||
>b('foo') : string
|
||||
>b : B
|
||||
>'foo' : string
|
||||
>'foo' : "foo"
|
||||
>charAt : (pos: number) => string
|
||||
>0 : number
|
||||
|
||||
@@ -32,7 +32,7 @@ interface A {
|
||||
>A : A
|
||||
|
||||
(x: 'A1'): string;
|
||||
>x : 'A1'
|
||||
>x : "A1"
|
||||
|
||||
(x: string): void;
|
||||
>x : string
|
||||
@@ -43,21 +43,21 @@ interface B extends A {
|
||||
>A : A
|
||||
|
||||
(x: 'B1'): number;
|
||||
>x : 'B1'
|
||||
>x : "B1"
|
||||
}
|
||||
|
||||
interface A {
|
||||
>A : A
|
||||
|
||||
(x: 'A2'): boolean;
|
||||
>x : 'A2'
|
||||
>x : "A2"
|
||||
}
|
||||
|
||||
interface B {
|
||||
>B : B
|
||||
|
||||
(x: 'B2'): string[];
|
||||
>x : 'B2'
|
||||
>x : "B2"
|
||||
}
|
||||
|
||||
interface C1 extends B {
|
||||
@@ -65,7 +65,7 @@ interface C1 extends B {
|
||||
>B : B
|
||||
|
||||
(x: 'C1'): number[];
|
||||
>x : 'C1'
|
||||
>x : "C1"
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
@@ -73,7 +73,7 @@ interface C2 extends B {
|
||||
>B : B
|
||||
|
||||
(x: 'C2'): boolean[];
|
||||
>x : 'C2'
|
||||
>x : "C2"
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
@@ -82,7 +82,7 @@ interface C extends C1, C2 {
|
||||
>C2 : C2
|
||||
|
||||
(x: 'C'): string;
|
||||
>x : 'C'
|
||||
>x : "C"
|
||||
}
|
||||
|
||||
var c: C;
|
||||
@@ -94,25 +94,25 @@ var x1: string[] = c('B2');
|
||||
>x1 : string[]
|
||||
>c('B2') : string[]
|
||||
>c : C
|
||||
>'B2' : string
|
||||
>'B2' : "B2"
|
||||
|
||||
var x2: number = c('B1');
|
||||
>x2 : number
|
||||
>c('B1') : number
|
||||
>c : C
|
||||
>'B1' : string
|
||||
>'B1' : "B1"
|
||||
|
||||
var x3: boolean = c('A2');
|
||||
>x3 : boolean
|
||||
>c('A2') : boolean
|
||||
>c : C
|
||||
>'A2' : string
|
||||
>'A2' : "A2"
|
||||
|
||||
var x4: string = c('A1');
|
||||
>x4 : string
|
||||
>c('A1') : string
|
||||
>c : C
|
||||
>'A1' : string
|
||||
>'A1' : "A1"
|
||||
|
||||
var x5: void = c('A0');
|
||||
>x5 : void
|
||||
@@ -124,19 +124,19 @@ var x6: number[] = c('C1');
|
||||
>x6 : number[]
|
||||
>c('C1') : number[]
|
||||
>c : C
|
||||
>'C1' : string
|
||||
>'C1' : "C1"
|
||||
|
||||
var x7: boolean[] = c('C2');
|
||||
>x7 : boolean[]
|
||||
>c('C2') : boolean[]
|
||||
>c : C
|
||||
>'C2' : string
|
||||
>'C2' : "C2"
|
||||
|
||||
var x8: string = c('C');
|
||||
>x8 : string
|
||||
>c('C') : string
|
||||
>c : C
|
||||
>'C' : string
|
||||
>'C' : "C"
|
||||
|
||||
var x9: void = c('generic');
|
||||
>x9 : void
|
||||
|
||||
@@ -3,13 +3,13 @@ interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
(x: 'a'): number;
|
||||
>x : 'a'
|
||||
>x : "a"
|
||||
|
||||
(x: string): any;
|
||||
>x : string
|
||||
|
||||
new (x: 'a'): any;
|
||||
>x : 'a'
|
||||
>x : "a"
|
||||
|
||||
new (x: string): Object;
|
||||
>x : string
|
||||
@@ -24,7 +24,7 @@ var r = f('a');
|
||||
>r : number
|
||||
>f('a') : number
|
||||
>f : Foo
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
|
||||
var r2 = f('A');
|
||||
>r2 : any
|
||||
@@ -36,7 +36,7 @@ var r3 = new f('a');
|
||||
>r3 : any
|
||||
>new f('a') : any
|
||||
>f : Foo
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
|
||||
var r4 = new f('A');
|
||||
>r4 : Object
|
||||
|
||||
@@ -6,7 +6,5 @@ export var x;
|
||||
//// [file2.ts]
|
||||
var y;
|
||||
|
||||
//// [file1.js]
|
||||
export var x;
|
||||
//// [all.js]
|
||||
var y;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
tests/cases/compiler/literalsInComputedProperties1.ts(40,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/literalsInComputedProperties1.ts(41,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/literalsInComputedProperties1.ts(42,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/literalsInComputedProperties1.ts(43,5): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/compiler/literalsInComputedProperties1.ts (4 errors) ====
|
||||
|
||||
let x = {
|
||||
1:1,
|
||||
[2]:1,
|
||||
"3":1,
|
||||
["4"]:1
|
||||
}
|
||||
x[1].toExponential();
|
||||
x[2].toExponential();
|
||||
x[3].toExponential();
|
||||
x[4].toExponential();
|
||||
|
||||
interface A {
|
||||
1:number;
|
||||
[2]:number;
|
||||
"3":number;
|
||||
["4"]:number;
|
||||
}
|
||||
|
||||
let y:A;
|
||||
y[1].toExponential();
|
||||
y[2].toExponential();
|
||||
y[3].toExponential();
|
||||
y[4].toExponential();
|
||||
|
||||
class C {
|
||||
1:number;
|
||||
[2]:number;
|
||||
"3":number;
|
||||
["4"]:number;
|
||||
}
|
||||
|
||||
let z:C;
|
||||
z[1].toExponential();
|
||||
z[2].toExponential();
|
||||
z[3].toExponential();
|
||||
z[4].toExponential();
|
||||
|
||||
enum X {
|
||||
1 = 1,
|
||||
~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
[2] = 2,
|
||||
~~~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
"3" = 3,
|
||||
~~~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
["4"] = 4,
|
||||
~~~~~
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
"foo" = 5,
|
||||
["bar"] = 6
|
||||
}
|
||||
|
||||
let a = X["foo"];
|
||||
let a0 = X["bar"];
|
||||
|
||||
// TODO: make sure that enum still disallow template literals as member names
|
||||
@@ -0,0 +1,94 @@
|
||||
//// [literalsInComputedProperties1.ts]
|
||||
|
||||
let x = {
|
||||
1:1,
|
||||
[2]:1,
|
||||
"3":1,
|
||||
["4"]:1
|
||||
}
|
||||
x[1].toExponential();
|
||||
x[2].toExponential();
|
||||
x[3].toExponential();
|
||||
x[4].toExponential();
|
||||
|
||||
interface A {
|
||||
1:number;
|
||||
[2]:number;
|
||||
"3":number;
|
||||
["4"]:number;
|
||||
}
|
||||
|
||||
let y:A;
|
||||
y[1].toExponential();
|
||||
y[2].toExponential();
|
||||
y[3].toExponential();
|
||||
y[4].toExponential();
|
||||
|
||||
class C {
|
||||
1:number;
|
||||
[2]:number;
|
||||
"3":number;
|
||||
["4"]:number;
|
||||
}
|
||||
|
||||
let z:C;
|
||||
z[1].toExponential();
|
||||
z[2].toExponential();
|
||||
z[3].toExponential();
|
||||
z[4].toExponential();
|
||||
|
||||
enum X {
|
||||
1 = 1,
|
||||
[2] = 2,
|
||||
"3" = 3,
|
||||
["4"] = 4,
|
||||
"foo" = 5,
|
||||
["bar"] = 6
|
||||
}
|
||||
|
||||
let a = X["foo"];
|
||||
let a0 = X["bar"];
|
||||
|
||||
// TODO: make sure that enum still disallow template literals as member names
|
||||
|
||||
//// [literalsInComputedProperties1.js]
|
||||
var x = (_a = {
|
||||
1: 1
|
||||
},
|
||||
_a[2] = 1,
|
||||
_a["3"] = 1,
|
||||
_a["4"] = 1,
|
||||
_a
|
||||
);
|
||||
x[1].toExponential();
|
||||
x[2].toExponential();
|
||||
x[3].toExponential();
|
||||
x[4].toExponential();
|
||||
var y;
|
||||
y[1].toExponential();
|
||||
y[2].toExponential();
|
||||
y[3].toExponential();
|
||||
y[4].toExponential();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var z;
|
||||
z[1].toExponential();
|
||||
z[2].toExponential();
|
||||
z[3].toExponential();
|
||||
z[4].toExponential();
|
||||
var X;
|
||||
(function (X) {
|
||||
X[X["1"] = 1] = "1";
|
||||
X[X[2] = 2] = 2;
|
||||
X[X["3"] = 3] = "3";
|
||||
X[X["4"] = 4] = "4";
|
||||
X[X["foo"] = 5] = "foo";
|
||||
X[X["bar"] = 6] = "bar";
|
||||
})(X || (X = {}));
|
||||
var a = X["foo"];
|
||||
var a0 = X["bar"];
|
||||
var _a;
|
||||
// TODO: make sure that enum still disallow template literals as member names
|
||||
@@ -17,20 +17,20 @@ class C {
|
||||
>y : any
|
||||
|
||||
public bar(x: 'hi');
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : 'hi'
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : "hi"
|
||||
|
||||
public bar(x: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : string
|
||||
|
||||
public bar(x: number, y: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public bar(x: any, y?: any) { }
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@@ -49,20 +49,20 @@ class C {
|
||||
>y : any
|
||||
|
||||
public static bar(x: 'hi');
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : 'hi'
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : "hi"
|
||||
|
||||
public static bar(x: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : string
|
||||
|
||||
public static bar(x: number, y: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public static bar(x: any, y?: any) { }
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : any
|
||||
>y : any
|
||||
}
|
||||
@@ -88,22 +88,22 @@ class D<T> {
|
||||
>y : any
|
||||
|
||||
public bar(x: 'hi');
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; }
|
||||
>x : 'hi'
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; }
|
||||
>x : "hi"
|
||||
|
||||
public bar(x: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; }
|
||||
>x : string
|
||||
|
||||
public bar(x: T, y: T);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; }
|
||||
>x : T
|
||||
>T : T
|
||||
>y : T
|
||||
>T : T
|
||||
|
||||
public bar(x: any, y?: any) { }
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: T, y: T): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: T, y: T): any; }
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
@@ -122,20 +122,20 @@ class D<T> {
|
||||
>y : any
|
||||
|
||||
public static bar(x: 'hi');
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : 'hi'
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : "hi"
|
||||
|
||||
public static bar(x: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : string
|
||||
|
||||
public static bar(x: number, y: string);
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public static bar(x: any, y?: any) { }
|
||||
>bar : { (x: 'hi'): any; (x: string): any; (x: number, y: string): any; }
|
||||
>bar : { (x: "hi"): any; (x: string): any; (x: number, y: string): any; }
|
||||
>x : any
|
||||
>y : any
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ if (elementA instanceof FileMatch && elementB instanceof FileMatch) {
|
||||
} else if (elementA instanceof Match && elementB instanceof Match) {
|
||||
>elementA instanceof Match && elementB instanceof Match : boolean
|
||||
>elementA instanceof Match : boolean
|
||||
>elementA : FileMatch | Match
|
||||
>elementA : Match | FileMatch
|
||||
>Match : typeof Match
|
||||
>elementB instanceof Match : boolean
|
||||
>elementB : FileMatch | Match
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
|
||||
|
||||
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
|
||||
class A { }
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
class B { }
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
|
||||
class A { }
|
||||
>A : Symbol(A, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
class B { }
|
||||
>B : Symbol(B, Decl(b.ts, 0, 0))
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
|
||||
class A { }
|
||||
>A : A
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
class B { }
|
||||
>B : B
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
error TS5053: Option 'out' cannot be specified with option 'outFile'.
|
||||
error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'out' cannot be specified with option 'outFile'.
|
||||
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --out.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
|
||||
// --out and --outFile error
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/outModuleConcatAmd.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
export class A { }
|
||||
|
||||
//// [b.ts]
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
|
||||
//// [all.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
});
|
||||
define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) {
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(a_1.A);
|
||||
exports.B = B;
|
||||
});
|
||||
//# sourceMappingURL=all.js.map
|
||||
|
||||
//// [all.d.ts]
|
||||
declare module "tests/cases/compiler/ref/a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare module "tests/cases/compiler/b" {
|
||||
import { A } from "tests/cases/compiler/ref/a";
|
||||
export class B extends A {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//// [all.js.map]
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;IACA;QAAAA;QAAiBC,CAACA;QAADD,QAACA;IAADA,CAACA,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA;;;ICAlB;QAAuBE,qBAACA;QAAxBA;YAAuBC,8BAACA;QAAGA,CAACA;QAADD,QAACA;IAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;IAAf,SAAC,IAAc,CAAA"}
|
||||
@@ -0,0 +1,164 @@
|
||||
===================================================================
|
||||
JsFile: all.js
|
||||
mapUrl: all.js.map
|
||||
sourceRoot:
|
||||
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:all.js
|
||||
sourceFile:tests/cases/compiler/ref/a.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>var __extends = (this && this.__extends) || function (d, b) {
|
||||
>>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
>>> function __() { this.constructor = d; }
|
||||
>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
>>>};
|
||||
>>>define("tests/cases/compiler/ref/a", ["require", "exports"], function (require, exports) {
|
||||
>>> var A = (function () {
|
||||
1 >^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
1 >Emitted(7, 5) Source(2, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> function A() {
|
||||
1->^^^^^^^^
|
||||
2 > ^^->
|
||||
1->
|
||||
1->Emitted(8, 9) Source(2, 1) + SourceIndex(0) name (A)
|
||||
---
|
||||
>>> }
|
||||
1->^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^->
|
||||
1->export class A {
|
||||
2 > }
|
||||
1->Emitted(9, 9) Source(2, 18) + SourceIndex(0) name (A.constructor)
|
||||
2 >Emitted(9, 10) Source(2, 19) + SourceIndex(0) name (A.constructor)
|
||||
---
|
||||
>>> return A;
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^^^
|
||||
1->
|
||||
2 > }
|
||||
1->Emitted(10, 9) Source(2, 18) + SourceIndex(0) name (A)
|
||||
2 >Emitted(10, 17) Source(2, 19) + SourceIndex(0) name (A)
|
||||
---
|
||||
>>> })();
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 >
|
||||
4 > ^^^^
|
||||
5 > ^^^^^^^^^^->
|
||||
1 >
|
||||
2 > }
|
||||
3 >
|
||||
4 > export class A { }
|
||||
1 >Emitted(11, 5) Source(2, 18) + SourceIndex(0) name (A)
|
||||
2 >Emitted(11, 6) Source(2, 19) + SourceIndex(0) name (A)
|
||||
3 >Emitted(11, 6) Source(2, 1) + SourceIndex(0)
|
||||
4 >Emitted(11, 10) Source(2, 19) + SourceIndex(0)
|
||||
---
|
||||
>>> exports.A = A;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^
|
||||
3 > ^^^^
|
||||
4 > ^
|
||||
1->
|
||||
2 > A
|
||||
3 > { }
|
||||
4 >
|
||||
1->Emitted(12, 5) Source(2, 14) + SourceIndex(0)
|
||||
2 >Emitted(12, 14) Source(2, 15) + SourceIndex(0)
|
||||
3 >Emitted(12, 18) Source(2, 19) + SourceIndex(0)
|
||||
4 >Emitted(12, 19) Source(2, 19) + SourceIndex(0)
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:all.js
|
||||
sourceFile:tests/cases/compiler/b.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>});
|
||||
>>>define("tests/cases/compiler/b", ["require", "exports", "tests/cases/compiler/ref/a"], function (require, exports, a_1) {
|
||||
>>> var B = (function (_super) {
|
||||
1 >^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >import {A} from "./ref/a";
|
||||
>
|
||||
1 >Emitted(15, 5) Source(2, 1) + SourceIndex(1)
|
||||
---
|
||||
>>> __extends(B, _super);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^
|
||||
1->export class B extends
|
||||
2 > A
|
||||
1->Emitted(16, 9) Source(2, 24) + SourceIndex(1) name (B)
|
||||
2 >Emitted(16, 30) Source(2, 25) + SourceIndex(1) name (B)
|
||||
---
|
||||
>>> function B() {
|
||||
1 >^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
1 >Emitted(17, 9) Source(2, 1) + SourceIndex(1) name (B)
|
||||
---
|
||||
>>> _super.apply(this, arguments);
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->export class B extends
|
||||
2 > A
|
||||
1->Emitted(18, 13) Source(2, 24) + SourceIndex(1) name (B.constructor)
|
||||
2 >Emitted(18, 43) Source(2, 25) + SourceIndex(1) name (B.constructor)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^->
|
||||
1 > {
|
||||
2 > }
|
||||
1 >Emitted(19, 9) Source(2, 28) + SourceIndex(1) name (B.constructor)
|
||||
2 >Emitted(19, 10) Source(2, 29) + SourceIndex(1) name (B.constructor)
|
||||
---
|
||||
>>> return B;
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^^^
|
||||
1->
|
||||
2 > }
|
||||
1->Emitted(20, 9) Source(2, 28) + SourceIndex(1) name (B)
|
||||
2 >Emitted(20, 17) Source(2, 29) + SourceIndex(1) name (B)
|
||||
---
|
||||
>>> })(a_1.A);
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 >
|
||||
4 > ^^
|
||||
5 > ^^^^^
|
||||
6 > ^^
|
||||
7 > ^^^^^->
|
||||
1 >
|
||||
2 > }
|
||||
3 >
|
||||
4 > export class B extends
|
||||
5 > A
|
||||
6 > { }
|
||||
1 >Emitted(21, 5) Source(2, 28) + SourceIndex(1) name (B)
|
||||
2 >Emitted(21, 6) Source(2, 29) + SourceIndex(1) name (B)
|
||||
3 >Emitted(21, 6) Source(2, 1) + SourceIndex(1)
|
||||
4 >Emitted(21, 8) Source(2, 24) + SourceIndex(1)
|
||||
5 >Emitted(21, 13) Source(2, 25) + SourceIndex(1)
|
||||
6 >Emitted(21, 15) Source(2, 29) + SourceIndex(1)
|
||||
---
|
||||
>>> exports.B = B;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^
|
||||
3 > ^^^^
|
||||
4 > ^
|
||||
1->
|
||||
2 > B
|
||||
3 > extends A { }
|
||||
4 >
|
||||
1->Emitted(22, 5) Source(2, 14) + SourceIndex(1)
|
||||
2 >Emitted(22, 14) Source(2, 15) + SourceIndex(1)
|
||||
3 >Emitted(22, 18) Source(2, 29) + SourceIndex(1)
|
||||
4 >Emitted(22, 19) Source(2, 29) + SourceIndex(1)
|
||||
---
|
||||
>>>});
|
||||
>>>//# sourceMappingURL=all.js.map
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/ref/a.ts ===
|
||||
|
||||
export class A { }
|
||||
>A : Symbol(A, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {A} from "./ref/a";
|
||||
>A : Symbol(A, Decl(b.ts, 0, 8))
|
||||
|
||||
export class B extends A { }
|
||||
>B : Symbol(B, Decl(b.ts, 0, 26))
|
||||
>A : Symbol(A, Decl(b.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/ref/a.ts ===
|
||||
|
||||
export class A { }
|
||||
>A : A
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {A} from "./ref/a";
|
||||
>A : typeof A
|
||||
|
||||
export class B extends A { }
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
|
||||
|
||||
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
==== tests/cases/compiler/ref/a.ts (0 errors) ====
|
||||
|
||||
// This should be an error
|
||||
|
||||
export class A { }
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [tests/cases/compiler/outModuleConcatCommonjs.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
// This should be an error
|
||||
|
||||
export class A { }
|
||||
|
||||
//// [b.ts]
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
|
||||
//// [all.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
// This should be an error
|
||||
//# sourceMappingURL=all.js.map
|
||||
|
||||
//// [all.d.ts]
|
||||
declare module "tests/cases/compiler/ref/a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare module "tests/cases/compiler/b" {
|
||||
import { A } from "tests/cases/compiler/ref/a";
|
||||
export class B extends A {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//// [all.js.map]
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,0BAA0B"}
|
||||
@@ -0,0 +1,26 @@
|
||||
===================================================================
|
||||
JsFile: all.js
|
||||
mapUrl: all.js.map
|
||||
sourceRoot:
|
||||
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:all.js
|
||||
sourceFile:tests/cases/compiler/ref/a.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>var __extends = (this && this.__extends) || function (d, b) {
|
||||
>>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
>>> function __() { this.constructor = d; }
|
||||
>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
>>>};
|
||||
>>>// This should be an error
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^->
|
||||
1 >
|
||||
>
|
||||
2 >// This should be an error
|
||||
1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0)
|
||||
2 >Emitted(6, 27) Source(2, 27) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=all.js.map
|
||||
@@ -0,0 +1,13 @@
|
||||
error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
|
||||
|
||||
!!! error TS6082: Only 'amd' and 'system' modules are supported alongside --outFile.
|
||||
==== tests/cases/compiler/ref/a.ts (0 errors) ====
|
||||
|
||||
// This should be an error
|
||||
|
||||
export class A { }
|
||||
|
||||
==== tests/cases/compiler/b.ts (0 errors) ====
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/compiler/outModuleConcatES6.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
// This should be an error
|
||||
|
||||
export class A { }
|
||||
|
||||
//// [b.ts]
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
|
||||
//// [all.js]
|
||||
// This should be an error
|
||||
//# sourceMappingURL=all.js.map
|
||||
|
||||
//// [all.d.ts]
|
||||
declare module "tests/cases/compiler/ref/a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare module "tests/cases/compiler/b" {
|
||||
import { A } from "tests/cases/compiler/ref/a";
|
||||
export class B extends A {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//// [all.js.map]
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AACA,0BAA0B"}
|
||||
@@ -0,0 +1,21 @@
|
||||
===================================================================
|
||||
JsFile: all.js
|
||||
mapUrl: all.js.map
|
||||
sourceRoot:
|
||||
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:all.js
|
||||
sourceFile:tests/cases/compiler/ref/a.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>// This should be an error
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^^->
|
||||
1 >
|
||||
>
|
||||
2 >// This should be an error
|
||||
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
|
||||
2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=all.js.map
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [tests/cases/compiler/outModuleConcatSystem.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
export class A { }
|
||||
|
||||
//// [b.ts]
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
|
||||
//// [all.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
System.register("tests/cases/compiler/ref/a", [], function(exports_1) {
|
||||
var A;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
exports_1("A", A);
|
||||
}
|
||||
}
|
||||
});
|
||||
System.register("tests/cases/compiler/b", ["tests/cases/compiler/ref/a"], function(exports_2) {
|
||||
var a_1;
|
||||
var B;
|
||||
return {
|
||||
setters:[
|
||||
function (a_1_1) {
|
||||
a_1 = a_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(a_1.A);
|
||||
exports_2("B", B);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=all.js.map
|
||||
|
||||
//// [all.d.ts]
|
||||
declare module "tests/cases/compiler/ref/a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare module "tests/cases/compiler/b" {
|
||||
import { A } from "tests/cases/compiler/ref/a";
|
||||
export class B extends A {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//// [all.js.map]
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":";;;;;;;;;;YACA;gBAAAA;gBAAiBC,CAACA;gBAADD,QAACA;YAADA,CAACA,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA;;;;;;;;;;;;;YCAlB;gBAAuBE,qBAACA;gBAAxBA;oBAAuBC,8BAACA;gBAAGA,CAACA;gBAADD,QAACA;YAADA,CAACA,AAA5B,EAAuB,KAAC,EAAI;YAA5B,iBAA4B,CAAA"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user