diff --git a/Gulpfile.ts b/Gulpfile.ts index 633a1387ab6..3d4bae39a32 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -390,7 +390,7 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => { .pipe(localCompilerProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/compiler")); }); gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { @@ -422,7 +422,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { file.path = nodeStandaloneDefinitionsFile; return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); })) - ]).pipe(gulp.dest(".")); + ]).pipe(gulp.dest("src/services")); }); // cancellationToken.js @@ -448,7 +448,7 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => { .pipe(cancellationTokenProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/server/typingsInstaller")); }); const serverFile = path.join(builtLocalDirectory, "tsserver.js"); @@ -461,7 +461,7 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke .pipe(serverProject()) .pipe(prependCopyright()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/server")); }); const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); @@ -556,7 +556,7 @@ gulp.task(run, false, [servicesFile], () => { .pipe(sourcemaps.init()) .pipe(testProject()) .pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" })) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/harness")); }); const internalTests = "internal/"; @@ -778,7 +778,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo }); })) .pipe(sourcemaps.write(".", { includeContent: false })) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("src/harness")); }); diff --git a/Jakefile.js b/Jakefile.js index 17152285f2a..971f0be0fde 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -328,8 +328,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts if (opts.stripInternal) { options += " --stripInternal"; } - - options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters"; + options += " --target es5"; + if (opts.lib) { + options += " --lib " + opts.lib + } + else { + options += " --lib es5,scripthost" + } + options += " --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); @@ -1111,7 +1117,7 @@ desc("Compiles tslint rules to js"); task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") }); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" }); }); desc("Emit the start of the build-rules fold"); diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 2fc15c3a256..e675ba87417 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1742,6 +1742,7 @@ declare namespace ts.server.protocol { insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; diff --git a/scripts/parallel-lint.js b/scripts/parallel-lint.js index aec9960ce47..2ac84667d6f 100644 --- a/scripts/parallel-lint.js +++ b/scripts/parallel-lint.js @@ -1,5 +1,6 @@ var tslint = require("tslint"); var fs = require("fs"); +var path = require("path"); function getLinterOptions() { return { @@ -9,7 +10,7 @@ function getLinterOptions() { }; } function getLinterConfiguration() { - return require("../tslint.json"); + return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json")); } function lintFileContents(options, configuration, path, contents) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8f2c32721f7..9de2a527754 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -141,7 +141,7 @@ namespace ts { getAugmentedPropertiesOfType, getRootSymbols, getContextualType: node => { - node = getParseTreeNode(node, isExpression) + node = getParseTreeNode(node, isExpression); return node ? getContextualType(node) : undefined; }, getFullyQualifiedName, @@ -197,6 +197,8 @@ namespace ts { const evolvingArrayTypes: EvolvingArrayType[] = []; const unknownSymbol = createSymbol(SymbolFlags.Property, "unknown"); + const untypedModuleSymbol = createSymbol(SymbolFlags.ValueModule, ""); + untypedModuleSymbol.exports = createMap(); const resolvingSymbol = createSymbol(0, "__resolving__"); const anyType = createIntrinsicType(TypeFlags.Any, "any"); @@ -1227,7 +1229,7 @@ namespace ts { if (moduleSymbol) { let exportDefaultSymbol: Symbol; - if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + if (isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol)) { exportDefaultSymbol = moduleSymbol; } else { @@ -1307,7 +1309,7 @@ namespace ts { if (targetSymbol) { const name = specifier.propertyName || specifier.name; if (name.text) { - if (isShorthandAmbientModuleSymbol(moduleSymbol)) { + if (isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } @@ -1560,15 +1562,19 @@ namespace ts { if (isForAugmentation) { const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); + return undefined; } else if (compilerOptions.noImplicitAny && moduleNotFoundError) { error(errorNode, Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + return undefined; } - // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. - return undefined; + // Unlike a failed import, an untyped module produces a dummy symbol. + // This is checked for by `isUntypedOrShorthandAmbientModuleSymbol`. + // This must be different than `unknownSymbol` because `getBaseConstructorTypeOfClass` won't fail for `unknownSymbol`. + return untypedModuleSymbol; } if (moduleNotFoundError) { @@ -3753,7 +3759,7 @@ namespace ts { function getTypeOfFuncClassEnumModule(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & SymbolFlags.Module && isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & SymbolFlags.Module && isUntypedOrShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -11578,7 +11584,7 @@ namespace ts { if (isBindingPattern(declaration.parent)) { const parentDeclaration = declaration.parent.parent; const name = declaration.propertyName || declaration.name; - if (isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== SyntaxKind.BindingElement && parentDeclaration.type && !isBindingPattern(name)) { const text = getTextOfPropertyName(name); @@ -16125,7 +16131,7 @@ namespace ts { } function checkDeclarationInitializer(declaration: VariableLikeDeclaration) { - const type = checkExpressionCached(declaration.initializer); + const type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return getCombinedNodeFlags(declaration) & NodeFlags.Const || getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -16198,10 +16204,12 @@ namespace ts { // Returns the type of an expression. Unlike checkExpression, this function is simply concerned // with computing the type and may not fully check all contained sub-expressions for errors. - function getTypeOfExpression(node: Expression) { + // A cache argument of true indicates that if the function performs a full type check, it is ok + // to cache the result. + function getTypeOfExpression(node: Expression, cache?: boolean) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword) { + if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) { const funcType = checkNonNullExpression((node).expression); const signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -16211,7 +16219,7 @@ namespace ts { // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions // should have a parameter that indicates whether full error checking is required such that // we can perform the optimizations locally. - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When @@ -20668,7 +20676,7 @@ namespace ts { } if (potentialNewTargetCollisions.length) { - forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope) + forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); potentialNewTargetCollisions.length = 0; } @@ -21138,7 +21146,15 @@ namespace ts { } if (isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + let typeFromTypeNode = getTypeFromTypeNode(node); + + if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + const containingClass = getContainingClass(node); + const classType = getTypeOfNode(containingClass) as InterfaceType; + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + + return typeFromTypeNode; } if (isPartOfExpression(node)) { @@ -21148,7 +21164,10 @@ namespace ts { if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + const classNode = getContainingClass(node); + const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)) as InterfaceType; + const baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { @@ -21316,7 +21335,7 @@ namespace ts { function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean { let moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression); - if (!moduleSymbol || isShorthandAmbientModuleSymbol(moduleSymbol)) { + if (!moduleSymbol || isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol)) { // If the module is not found or is shorthand, assume that it may export a value. return true; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5550e2f62c2..c380a39611d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -84,7 +84,7 @@ namespace ts { this.index++; return { value: this.selector(this.data, this.keys[index]), done: false }; } - return { value: undefined as never, done: true } + return { value: undefined as never, done: true }; } } @@ -140,7 +140,7 @@ namespace ts { action(this.data[key], key); } } - } + }; } export function createFileMap(keyMapper?: (key: string) => string): FileMap { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 12411cabd56..4a542ab30c7 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1164,7 +1164,7 @@ namespace ts { emitTypeParameters(node.typeParameters); const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - node.name + node.name; emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); } emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index f9fbe5b01c1..1911605a0a6 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -675,7 +675,7 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations { - return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false); } /* @internal */ @@ -962,7 +962,7 @@ namespace ts { const result = cache && cache.get(containingDirectory); if (result) { if (traceEnabled) { - trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName) + trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index df87b17955b..bb1732b57ea 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -121,13 +121,13 @@ namespace ts { enableEmitNotification, isSubstitutionEnabled, isEmitNotificationEnabled, - get onSubstituteNode() { return onSubstituteNode }, + get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, - get onEmitNode() { return onEmitNode }, + get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed."); Debug.assert(value !== undefined, "Value must not be 'undefined'"); diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 03d4b9ce328..fd2c287d0e0 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2690,7 +2690,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - addRange(statements, lexicalEnvironment) + addRange(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 0240ddf38fe..e74e60cd996 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1152,7 +1152,7 @@ namespace ts { createIdentifier("__esModule"), createLiteral(true) ) - ) + ); } else { statement = createStatement( diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 142ab9767c4..90fa35a3636 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -621,6 +621,7 @@ namespace ts { export interface TypeParameterDeclaration extends Declaration { kind: SyntaxKind.TypeParameter; + parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -648,7 +649,7 @@ namespace ts { export interface VariableDeclaration extends Declaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; + parent?: VariableDeclarationList | CatchClause; name: BindingName; // Declared variable name type?: TypeNode; // Optional type annotation initializer?: Expression; // Optional initializer @@ -656,11 +657,13 @@ namespace ts { export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; + parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } export interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; + parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; // Present on rest parameter name: BindingName; // Declared parameter name questionToken?: QuestionToken; // Present on optional parameter @@ -670,6 +673,7 @@ namespace ts { export interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; + parent?: BindingPattern; propertyName?: PropertyName; // Binding property name (in object binding pattern) dotDotDotToken?: DotDotDotToken; // Present on rest element (in object binding pattern) name: BindingName; // Declared binding element name @@ -751,11 +755,13 @@ namespace ts { export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } @@ -1324,14 +1330,17 @@ namespace ts { export interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; + parent?: TemplateExpression; } export interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; + parent?: TemplateSpan; } export interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; + parent?: TemplateSpan; } export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; @@ -1346,6 +1355,7 @@ namespace ts { // The template literal must have kind TemplateMiddleLiteral or TemplateTailLiteral. export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; + parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -1433,6 +1443,7 @@ namespace ts { export interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; + parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -1500,6 +1511,7 @@ namespace ts { /// The opening element of a ... JsxElement export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; + parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } @@ -1513,6 +1525,7 @@ namespace ts { export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; + parent?: JsxOpeningLikeElement; name: Identifier; /// JSX attribute initializers are optional; is sugar for initializer?: StringLiteral | JsxExpression; @@ -1520,22 +1533,26 @@ namespace ts { export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; + parent?: JsxOpeningLikeElement; expression: Expression; } export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; + parent?: JsxElement; tagName: JsxTagNameExpression; } export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } export interface JsxText extends Node { kind: SyntaxKind.JsxText; + parent?: JsxElement; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; @@ -1677,17 +1694,20 @@ namespace ts { export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; + parent?: SwitchStatement; clauses: NodeArray; } export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; + parent?: CaseBlock; expression: Expression; statements: NodeArray; } export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; + parent?: CaseBlock; statements: NodeArray; } @@ -1713,6 +1733,7 @@ namespace ts { export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; + parent?: TryStatement; variableDeclaration: VariableDeclaration; block: Block; } @@ -1756,6 +1777,7 @@ namespace ts { export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; + parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; token: SyntaxKind; types?: NodeArray; } @@ -1769,6 +1791,7 @@ namespace ts { export interface EnumMember extends Declaration { kind: SyntaxKind.EnumMember; + parent?: EnumDeclaration; // This does include ComputedPropertyName, but the parser will give an error // if it parses a ComputedPropertyName in an EnumMember name: PropertyName; @@ -1787,7 +1810,8 @@ namespace ts { export interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | StringLiteral; + parent?: ModuleBody | SourceFile; + name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; } @@ -1807,6 +1831,7 @@ namespace ts { export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; + parent?: ModuleDeclaration; statements: NodeArray; } @@ -1814,6 +1839,7 @@ namespace ts { export interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; + parent?: SourceFile | ModuleBlock; name: Identifier; // 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external @@ -1823,6 +1849,7 @@ namespace ts { export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; + parent?: ImportEqualsDeclaration; expression?: Expression; } @@ -1832,6 +1859,7 @@ namespace ts { // ImportClause information is shown at its declaration below. export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; + parent?: SourceFile | ModuleBlock; importClause?: ImportClause; moduleSpecifier: Expression; } @@ -1846,12 +1874,14 @@ namespace ts { // import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} export interface ImportClause extends Declaration { kind: SyntaxKind.ImportClause; + parent?: ImportDeclaration; name?: Identifier; // Default binding namedBindings?: NamedImportBindings; } export interface NamespaceImport extends Declaration { kind: SyntaxKind.NamespaceImport; + parent?: ImportClause; name: Identifier; } @@ -1863,17 +1893,20 @@ namespace ts { export interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; + parent?: SourceFile | ModuleBlock; exportClause?: NamedExports; moduleSpecifier?: Expression; } export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; + parent?: ImportClause; elements: NodeArray; } export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; + parent?: ExportDeclaration; elements: NodeArray; } @@ -1881,12 +1914,14 @@ namespace ts { export interface ImportSpecifier extends Declaration { kind: SyntaxKind.ImportSpecifier; + parent?: NamedImports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) name: Identifier; // Declared name } export interface ExportSpecifier extends Declaration { kind: SyntaxKind.ExportSpecifier; + parent?: NamedExports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) name: Identifier; // Declared name } @@ -1895,6 +1930,7 @@ namespace ts { export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; + parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } @@ -3261,7 +3297,7 @@ namespace ts { } export interface PluginImport { - name: string + name: string; } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 60d8d784d96..df24d3b2985 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -435,8 +435,8 @@ namespace ts { } /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ - export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + export function isUntypedOrShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean { + return !moduleSymbol.declarations || isShorthandAmbientModule(moduleSymbol.valueDeclaration); } function isShorthandAmbientModule(node: Node): boolean { @@ -3129,6 +3129,15 @@ namespace ts { return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } + export function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): node is ExpressionWithTypeArguments { + return node.kind === SyntaxKind.ExpressionWithTypeArguments + && isEntityNameExpression((node as ExpressionWithTypeArguments).expression) + && node.parent + && (node.parent).token === SyntaxKind.ImplementsKeyword + && node.parent.parent + && isClassLike(node.parent.parent); + } + export function isEntityNameExpression(node: Expression): node is EntityNameExpression { return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((node).expression); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 28c59d717c0..0df9f4f4dd2 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -585,7 +585,7 @@ namespace FourSlash { } private getGoToDefinition(): ts.DefinitionInfo[] { - return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); } public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { @@ -926,7 +926,7 @@ namespace FourSlash { function rangeToReferenceEntry(r: Range) { let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition } + return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; } } @@ -2136,7 +2136,7 @@ namespace FourSlash { const result = includeWhiteSpace ? actualText === expectedText - : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText) + : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); @@ -2173,7 +2173,7 @@ namespace FourSlash { start: diagnostic.start, length: diagnostic.length, code: diagnostic.code - } + }; }); const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8935da642d4..23e8106864a 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -44,7 +44,7 @@ declare namespace NodeJS { declare var window: {}; declare var XMLHttpRequest: { new(): XMLHttpRequest; -} +}; interface XMLHttpRequest { readonly readyState: number; readonly responseText: string; @@ -1017,7 +1017,7 @@ namespace Harness { } else { if (!es6TestLibFileNameSourceFileMap.get(libFileName)) { - es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)) + es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)); } } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 202b429fcbc..e7f32748570 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -779,7 +779,7 @@ namespace Harness.LanguageService { start: 0 }); return prev; - } + }; return proxy; } }), diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index 48558b5c1a3..114ee77fef1 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -496,7 +496,7 @@ namespace ts.projectSystem { const emitOutput = host.readFile(path + ".js"); assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline"); } - }) + }); it("should emit specified file", () => { const file1 = { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 2496a880bc5..1a5a5a12f9e 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -9,7 +9,7 @@ namespace ts { Harness.Baseline.runBaseline(`printerApi/${prefix}.${name}.js`, () => printCallback(createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed, ...options }))); }); - } + }; } describe("printFile", () => { diff --git a/src/harness/unittests/textStorage.ts b/src/harness/unittests/textStorage.ts index b4287f2610c..545d090df9b 100644 --- a/src/harness/unittests/textStorage.ts +++ b/src/harness/unittests/textStorage.ts @@ -65,6 +65,6 @@ namespace ts.textStorage { ts1.getLineInfo(0); assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 2"); - }) + }); }); } \ No newline at end of file diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index e356b52da6f..4d1b2a0b10c 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -628,7 +628,7 @@ namespace ts.projectSystem { checkProjectActualFiles(service.configuredProjects[0], []); checkProjectActualFiles(service.inferredProjects[0], [f1.path]); - }) + }); it("create configured project without file list", () => { const configFile: FileOrFolder = { @@ -1181,7 +1181,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let x: string"); @@ -1213,7 +1213,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let somelongname: string"); @@ -2040,7 +2040,7 @@ namespace ts.projectSystem { for (const f of [f2, f3]) { const scriptInfo = projectService.getScriptInfoForNormalizedPath(server.toNormalizedPath(f.path)); - assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`) + assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`); } }); @@ -2156,7 +2156,7 @@ namespace ts.projectSystem { projectFileName, rootFiles: [toExternalFile(f1.path)], options: {} - }) + }); projectService.openClientFile(f1.path, "let x = 1;\nlet y = 2;"); projectService.checkNumberOfProjects({ externalProjects: 1 }); @@ -3307,12 +3307,12 @@ namespace ts.projectSystem { isCancellationRequested: () => false, setRequest: requestId => { if (expectedRequestId === undefined) { - assert.isTrue(false, "unexpected call") + assert.isTrue(false, "unexpected call"); } assert.equal(requestId, expectedRequestId); }, resetRequest: noop - } + }; const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken); expectedRequestId = session.getNextSeq(); @@ -3359,13 +3359,13 @@ namespace ts.projectSystem { currentId = requestId; }, resetRequest(requestId) { - assert.equal(requestId, currentId, "unexpected request id in cancellation") + assert.equal(requestId, currentId, "unexpected request id in cancellation"); currentId = undefined; }, isCancellationRequested() { return requestToCancel === currentId; } - } + }; })(); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 7fa22c29c16..12e62aaa7b9 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -56,7 +56,7 @@ namespace ts.projectSystem { path: "/a/config.js", content: "export let x = 1" }; - const typesCache = "/cache" + const typesCache = "/cache"; const typesConfig = { path: typesCache + "/node_modules/@types/config/index.d.ts", content: "export let y: number;" @@ -74,7 +74,7 @@ namespace ts.projectSystem { super(host, { typesRegistry: createTypesRegistry("config"), globalTypingsCacheLocation: typesCache }); } installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) { - assert(false, "should not be called") + assert(false, "should not be called"); } })(); const service = createProjectService(host, { typingsInstaller: installer }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index d1bc57ee970..397de9ead30 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -140,7 +140,7 @@ namespace ts.server { getScriptKind: _ => undefined, hasMixedContent: (fileName, extraFileExtensions) => { const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension); - return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)) + return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)); } }; @@ -1377,7 +1377,7 @@ namespace ts.server { // close projects that were missing in the input list forEachKey(projectsToClose, externalProjectName => { - this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) + this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true); }); this.refreshInferredProjects(); diff --git a/src/server/project.ts b/src/server/project.ts index 7125acb2c5f..385816b1029 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -723,7 +723,7 @@ namespace ts.server { const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); referencedFiles.set(typeFilePath, true); - }) + }); } const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; @@ -745,7 +745,7 @@ namespace ts.server { const id = nextId; nextId++; return makeInferredProjectName(id); - } + }; })(); private _isJsInferredProject = false; diff --git a/src/server/protocol.ts b/src/server/protocol.ts index c7d27d80d25..d054867cd1c 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2218,6 +2218,7 @@ namespace ts.server.protocol { insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index be3ef34ce3a..e5df91fd930 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -48,7 +48,7 @@ namespace ts.server { public reloadFromFile(tempFileName?: string) { if (this.svc || (tempFileName !== this.fileName)) { - this.reload(this.getFileText(tempFileName)) + this.reload(this.getFileText(tempFileName)); } else { this.setText(undefined); diff --git a/src/server/server.ts b/src/server/server.ts index 2a5990f4252..2c68963ec5c 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -47,14 +47,14 @@ namespace ts.server { if (process.env.XDG_CACHE_HOME) { return process.env.XDG_CACHE_HOME; } - const usersDir = platformIsDarwin ? "Users" : "home" + const usersDir = platformIsDarwin ? "Users" : "home"; const homePath = (os.homedir && os.homedir()) || process.env.HOME || ((process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}`) || os.tmpdir(); const cacheFolder = platformIsDarwin ? "Library/Caches" - : ".cache" + : ".cache"; return combinePaths(normalizeSlashes(homePath), cacheFolder); } @@ -653,7 +653,7 @@ namespace ts.server { // this drive is unsafe - return no-op watcher return { close() { } }; } - } + }; } // Override sys.write because fs.writeSync is not reliable on Node 4 diff --git a/src/server/session.ts b/src/server/session.ts index f25fdb9c98f..b5e7e44970d 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -239,7 +239,7 @@ namespace ts.server { this.next = { immediate: action => this.immediate(action), delay: (ms, action) => this.delay(ms, action) - } + }; } public startNew(action: (next: NextStep) => void) { @@ -262,7 +262,7 @@ namespace ts.server { private immediate(action: () => void) { const requestId = this.requestId; - Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id") + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id"); this.setImmediateId(this.operationHost.getServerHost().setImmediate(() => { this.immediateId = undefined; this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); @@ -271,7 +271,7 @@ namespace ts.server { private delay(ms: number, action: () => void) { const requestId = this.requestId; - Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id") + Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id"); this.setTimerHandle(this.operationHost.getServerHost().setTimeout(() => { this.timerHandle = undefined; this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action)); @@ -351,7 +351,7 @@ namespace ts.server { logError: (err, cmd) => this.logError(err, cmd), sendRequestCompletedEvent: requestId => this.sendRequestCompletedEvent(requestId), isCancellationRequested: () => cancellationToken.isCancellationRequested() - } + }; this.errorCheck = new MultistepOperation(multistepOperationHost); this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 602a849b5cd..0a69d701953 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -61,9 +61,7 @@ namespace ts.server.typingsInstaller { return combinePaths(normalizeSlashes(globalTypingsCacheLocation), `node_modules/${TypesRegistryPackageName}/index.json`); } - type ExecSync = { - (command: string, options: { cwd: string, stdio?: "ignore" }): any - } + type ExecSync = (command: string, options: { cwd: string, stdio?: "ignore" }) => any; export class NodeTypingsInstaller extends TypingsInstaller { private readonly execSync: ExecSync; diff --git a/src/server/watchGuard/watchGuard.ts b/src/server/watchGuard/watchGuard.ts index 7a0307a9120..f57369aecb9 100644 --- a/src/server/watchGuard/watchGuard.ts +++ b/src/server/watchGuard/watchGuard.ts @@ -11,7 +11,7 @@ const fs: { watch(directoryName: string, options: any, callback: () => {}): any // This means that here we treat any result (success or exception) from fs.watch as success since it does not tear down the process. // The only case that should be considered as failure - when watchGuard process crashes. try { - const watcher = fs.watch(directoryName, { recursive: true }, () => ({})) + const watcher = fs.watch(directoryName, { recursive: true }, () => ({})); watcher.close(); } catch (_e) { diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index c751cf3871b..1f6bec41109 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -370,8 +370,8 @@ namespace ts.BreakpointResolver { } function textSpanFromVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan { - const declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === SyntaxKind.VariableDeclarationList && + variableDeclaration.parent.declarations[0] === variableDeclaration) { // First declaration - include let keyword return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } @@ -400,8 +400,8 @@ namespace ts.BreakpointResolver { return textSpanFromVariableDeclaration(variableDeclaration); } - const declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === SyntaxKind.VariableDeclarationList && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { // If we cannot set breakpoint on this declaration, set it on previous one // Because the variable declaration may be binding pattern and // we would like to set breakpoint in last binding element if that's the case, diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 22546e55ecc..16edce0a516 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -22,8 +22,8 @@ namespace ts.codefix { const classDecl = token.parent as ClassLikeDeclaration; const startPos = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; - const instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + const extendsNode = getClassExtendsHeritageClauseElement(classDecl); + const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 42488dc2aed..67b2242c8d9 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -17,7 +17,7 @@ namespace ts.codefix { } const startPos: number = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl); + const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); @@ -25,9 +25,9 @@ namespace ts.codefix { const result: CodeAction[] = []; for (const implementedTypeNode of implementedTypeNodes) { - const implementedType = checker.getTypeFromTypeNode(implementedTypeNode) as InterfaceType; // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. + const implementedType = checker.getTypeAtLocation(implementedTypeNode) as InterfaceType; const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); const nonPrivateMembers = implementedTypeSymbols.filter(symbol => !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private)); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 3eab994f84c..d20fc0129cd 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -23,8 +23,6 @@ namespace ts.codefix { * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ function getInsertionForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, newlineChar: string): string { - // const name = symbol.getName(); - const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return ""; @@ -34,6 +32,8 @@ namespace ts.codefix { const name = declaration.name ? declaration.name.getText() : undefined; const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); + const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + switch (declaration.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index a5394c17cdd..3e07efbc3de 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -3,8 +3,8 @@ namespace ts.codefix { type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; interface ImportCodeAction extends CodeAction { - kind: ImportCodeActionKind, - moduleSpecifier?: string + kind: ImportCodeActionKind; + moduleSpecifier?: string; } enum ModuleSpecifierComparison { @@ -75,7 +75,7 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; for (const key in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[key]) + result = concatenate(result, this.symbolIdToActionMap[key]); } return result; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 1bf57d33fdc..6a4ee3485de 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -16,11 +16,16 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag } = completionData; - if (isJsDocTagName) { + if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagNameCompletions() }; + } + + if (requestJsDocTag) { + // If the current position is a jsDoc tag, only tags should be provided for completion + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagCompletions() }; } const entries: CompletionEntry[] = []; @@ -54,7 +59,7 @@ namespace ts.Completions { } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { + if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { addRange(entries, keywordCompletions); } @@ -814,7 +819,10 @@ namespace ts.Completions { function getCompletionData(typeChecker: TypeChecker, log: (message: string) => void, sourceFile: SourceFile, position: number) { const isJavaScriptFile = isSourceFileJavaScript(sourceFile); - let isJsDocTagName = false; + // JsDoc tag-name is just the name of the JSDoc tagname (exclude "@") + let requestJsDocTagName = false; + // JsDoc tag includes both "@" and tag-name + let requestJsDocTag = false; let start = timestamp(); const currentToken = getTokenAtPosition(sourceFile, position); @@ -826,10 +834,32 @@ namespace ts.Completions { log("getCompletionData: Is inside comment: " + (timestamp() - start)); if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { - isJsDocTagName = true; + if (hasDocComment(sourceFile, position)) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { + requestJsDocTagName = true; + } + else { + // When completion is requested without "@", we will have check to make sure that + // there are no comments prefix the request position. We will only allow "*" and space. + // e.g + // /** |c| /* + // + // /** + // |c| + // */ + // + // /** + // * |c| + // */ + // + // /** + // * |c| + // */ + const lineStart = getLineStartPositionForPosition(position, sourceFile); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + } } // Completion should work inside certain JsDoc tags. For example: @@ -839,7 +869,7 @@ namespace ts.Completions { const tag = getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { @@ -854,8 +884,8 @@ namespace ts.Completions { } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag }; } if (!insideJsDocTagExpression) { @@ -983,7 +1013,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName }; + return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 8576f48f6e3..bc1e50391c8 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -133,7 +133,7 @@ namespace ts.FindAllReferences { return { symbol }; } - if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { + if (ts.isUntypedOrShorthandAmbientModuleSymbol(aliasedSymbol)) { return { symbol, shorthandModuleSymbol: aliasedSymbol }; } @@ -422,7 +422,7 @@ namespace ts.FindAllReferences { name, textSpan: references[0].textSpan, displayParts: [{ text: name, kind: ScriptElementKind.keyword }] - } + }; return [{ definition, references }]; } @@ -613,7 +613,7 @@ namespace ts.FindAllReferences { const result: Node[] = []; for (const decl of classSymbol.members.get("__constructor").declarations) { - const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!; Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); result.push(ctrKeyword); } diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index de2481b8784..d0cf8c0aec8 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -42,7 +42,8 @@ namespace ts.JsDoc { "prop", "version" ]; - let jsDocCompletionEntries: CompletionEntry[]; + let jsDocTagNameCompletionEntries: CompletionEntry[]; + let jsDocTagCompletionEntries: CompletionEntry[]; export function getJsDocCommentsFromDeclarations(declarations: Declaration[]) { // Only collect doc comments from duplicate declarations once: @@ -88,8 +89,8 @@ namespace ts.JsDoc { return undefined; } - export function getAllJsDocCompletionEntries(): CompletionEntry[] { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, tagName => { + export function getJSDocTagNameCompletions(): CompletionEntry[] { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, tagName => { return { name: tagName, kind: ScriptElementKind.keyword, @@ -99,6 +100,17 @@ namespace ts.JsDoc { })); } + export function getJSDocTagCompletions(): CompletionEntry[] { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, tagName => { + return { + name: `@${tagName}`, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index a6afce1cc4f..b7b739b4244 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -2,7 +2,7 @@ namespace ts.SymbolDisplay { // TODO(drosen): use contextual SemanticMeaning. export function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { - const flags = symbol.getFlags(); + const { flags } = symbol; if (flags & SymbolFlags.Class) return getDeclarationOfKind(symbol, SyntaxKind.ClassExpression) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; @@ -11,10 +11,10 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement; if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ScriptElementKind.unknown) { if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement; - if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement; + if (flags & SymbolFlags.EnumMember) return ScriptElementKind.enumMemberElement; if (flags & SymbolFlags.Alias) return ScriptElementKind.alias; if (flags & SymbolFlags.Module) return ScriptElementKind.moduleElement; } @@ -22,7 +22,7 @@ namespace ts.SymbolDisplay { return result; } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, flags: SymbolFlags, location: Node) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, location: Node) { if (typeChecker.isUndefinedSymbol(symbol)) { return ScriptElementKind.variableElement; } @@ -32,6 +32,7 @@ namespace ts.SymbolDisplay { if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) { return ScriptElementKind.parameterElement; } + const { flags } = symbol; if (flags & SymbolFlags.Variable) { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; @@ -93,7 +94,7 @@ namespace ts.SymbolDisplay { const displayParts: SymbolDisplayPart[] = []; let documentation: SymbolDisplayPart[]; const symbolFlags = symbol.flags; - let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); let hasAddedSymbolInfo: boolean; const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location); let type: Type; @@ -319,6 +320,7 @@ namespace ts.SymbolDisplay { } } if (symbolFlags & SymbolFlags.EnumMember) { + symbolKind = ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); const declaration = symbol.declarations[0]; if (declaration.kind === SyntaxKind.EnumMember) { diff --git a/src/services/types.ts b/src/services/types.ts index 9253153c004..c7852db6d6e 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -706,8 +706,7 @@ namespace ts { /** enum E */ export const enumElement = "enum"; - // TODO: GH#9983 - export const enumMemberElement = "const"; + export const enumMemberElement = "enum member"; /** * Inside module and script only diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types index e0341d97ec3..7b01a59268f 100644 --- a/tests/baselines/reference/ambientRequireFunction.types +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -3,7 +3,7 @@ const fs = require("fs"); >fs : typeof "fs" ->require("fs") : any +>require("fs") : typeof "fs" >require : (moduleName: string) => any >"fs" : "fs" diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.js b/tests/baselines/reference/circularInferredTypeOfVariable.js new file mode 100644 index 00000000000..38c5334761a --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.js @@ -0,0 +1,44 @@ +//// [circularInferredTypeOfVariable.ts] + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { + return []; + } + + function bar(p: string[]): string[] { + return []; + } + + let a1: string[] | undefined = []; + + while (true) { + let a2 = foo(a1!); + a1 = await bar(a2); + } +}); + +//// [circularInferredTypeOfVariable.js] +// Repro from #14428 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +(() => __awaiter(this, void 0, void 0, function* () { + function foo(p) { + return []; + } + function bar(p) { + return []; + } + let a1 = []; + while (true) { + let a2 = foo(a1); + a1 = yield bar(a2); + } +})); diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.symbols b/tests/baselines/reference/circularInferredTypeOfVariable.symbols new file mode 100644 index 00000000000..653978f0e83 --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/circularInferredTypeOfVariable.ts === + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { +>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14)) +>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 4, 17)) + + return []; + } + + function bar(p: string[]): string[] { +>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5)) +>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 8, 17)) + + return []; + } + + let a1: string[] | undefined = []; +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) + + while (true) { + let a2 = foo(a1!); +>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11)) +>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14)) +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) + + a1 = await bar(a2); +>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7)) +>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5)) +>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11)) + } +}); diff --git a/tests/baselines/reference/circularInferredTypeOfVariable.types b/tests/baselines/reference/circularInferredTypeOfVariable.types new file mode 100644 index 00000000000..df227bd9ae0 --- /dev/null +++ b/tests/baselines/reference/circularInferredTypeOfVariable.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/circularInferredTypeOfVariable.ts === + +// Repro from #14428 + +(async () => { +>(async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }}) : () => Promise +>async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }} : () => Promise + + function foo(p: string[]): string[] { +>foo : (p: string[]) => string[] +>p : string[] + + return []; +>[] : undefined[] + } + + function bar(p: string[]): string[] { +>bar : (p: string[]) => string[] +>p : string[] + + return []; +>[] : undefined[] + } + + let a1: string[] | undefined = []; +>a1 : string[] +>[] : undefined[] + + while (true) { +>true : true + + let a2 = foo(a1!); +>a2 : string[] +>foo(a1!) : string[] +>foo : (p: string[]) => string[] +>a1! : string[] +>a1 : string[] + + a1 = await bar(a2); +>a1 = await bar(a2) : string[] +>a1 : string[] +>await bar(a2) : string[] +>bar(a2) : string[] +>bar : (p: string[]) => string[] +>a2 : string[] + } +}); diff --git a/tests/baselines/reference/controlFlowIterationErrors.errors.txt b/tests/baselines/reference/controlFlowIterationErrors.errors.txt index 1f090ccd35f..bc4b19b0602 100644 --- a/tests/baselines/reference/controlFlowIterationErrors.errors.txt +++ b/tests/baselines/reference/controlFlowIterationErrors.errors.txt @@ -6,15 +6,9 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(35,17): error Type 'string' is not assignable to type 'number'. tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(46,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(77,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. - Type 'true' is not assignable to type 'string | number'. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,13): error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. - Type 'true' is not assignable to type 'string | number'. -==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (8 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (4 errors) ==== let cond: boolean; @@ -104,11 +98,6 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error x = "0"; while (cond) { let y = asNumber(x); - ~ -!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - ~ -!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. -!!! error TS2345: Type 'true' is not assignable to type 'string | number'. x = y + 1; x; } @@ -120,11 +109,6 @@ tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(88,26): error while (cond) { x; let y = asNumber(x); - ~ -!!! error TS7022: 'y' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - ~ -!!! error TS2345: Argument of type 'string | number | boolean' is not assignable to parameter of type 'string | number'. -!!! error TS2345: Type 'true' is not assignable to type 'string | number'. x = y + 1; x; } diff --git a/tests/baselines/reference/extendsUntypedModule.errors.txt b/tests/baselines/reference/extendsUntypedModule.errors.txt new file mode 100644 index 00000000000..9a1c4235352 --- /dev/null +++ b/tests/baselines/reference/extendsUntypedModule.errors.txt @@ -0,0 +1,14 @@ +/a.ts(2,17): error TS2507: Type 'any' is not a constructor function type. + + +==== /a.ts (1 errors) ==== + import Foo from "foo"; + class A extends Foo { } + ~~~ +!!! error TS2507: Type 'any' is not a constructor function type. + +==== /node_modules/foo/index.js (0 errors) ==== + // Test that extending an untyped module is an error, unlike extending unknownSymbol. + + This file is not read. + \ No newline at end of file diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js new file mode 100644 index 00000000000..f86ded7e6cb --- /dev/null +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/extendsUntypedModule.ts] //// + +//// [index.js] +// Test that extending an untyped module is an error, unlike extending unknownSymbol. + +This file is not read. + +//// [a.ts] +import Foo from "foo"; +class A extends Foo { } + + +//// [a.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var foo_1 = require("foo"); +var A = (function (_super) { + __extends(A, _super); + function A() { + return _super !== null && _super.apply(this, arguments) || this; + } + return A; +}(foo_1["default"])); diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt index bb43d96b003..7d4dfa2cf5e 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt +++ b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt @@ -7,11 +7,10 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(18,10): error TS7024: F tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. -==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ==== +==== tests/cases/compiler/implicitAnyFromCircularInference.ts (10 errors) ==== // Error expected var a: typeof a; @@ -71,8 +70,6 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x class C { // Error expected s = foo(this); - ~~~~~~~~~~~~~~ -!!! error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. } class D { diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline index 142840b9f01..6dc27a4a5b3 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum1.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -95,7 +95,7 @@ "position": 21 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 21, @@ -156,7 +156,7 @@ "position": 34 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 34, @@ -357,7 +357,7 @@ "position": 71 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 71, @@ -488,7 +488,7 @@ "position": 89 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 89, @@ -619,7 +619,7 @@ "position": 107 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 107, @@ -717,7 +717,7 @@ "position": 135 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 135, @@ -778,7 +778,7 @@ "position": 143 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 143, @@ -839,7 +839,7 @@ "position": 156 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 156, @@ -1056,7 +1056,7 @@ "position": 205 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 205, @@ -1195,7 +1195,7 @@ "position": 229 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 229, @@ -1334,7 +1334,7 @@ "position": 253 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 253, diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline index efdff818b0f..43d0683faef 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum2.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -99,7 +99,7 @@ "position": 23 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 23, @@ -164,7 +164,7 @@ "position": 38 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 38, @@ -369,7 +369,7 @@ "position": 77 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 77, @@ -504,7 +504,7 @@ "position": 95 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 95, @@ -639,7 +639,7 @@ "position": 113 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 113, @@ -741,7 +741,7 @@ "position": 141 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 141, @@ -806,7 +806,7 @@ "position": 151 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 151, @@ -871,7 +871,7 @@ "position": 166 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 166, @@ -1092,7 +1092,7 @@ "position": 217 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 217, @@ -1235,7 +1235,7 @@ "position": 241 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 241, @@ -1378,7 +1378,7 @@ "position": 265 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 265, diff --git a/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline b/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline index 919816394e2..b9f6483f63a 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsEnum3.baseline @@ -34,7 +34,7 @@ "position": 13 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 13, @@ -99,7 +99,7 @@ "position": 23 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 23, @@ -164,7 +164,7 @@ "position": 38 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 38, @@ -369,7 +369,7 @@ "position": 77 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 77, @@ -504,7 +504,7 @@ "position": 98 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 98, @@ -639,7 +639,7 @@ "position": 119 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 119, @@ -741,7 +741,7 @@ "position": 150 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 150, @@ -806,7 +806,7 @@ "position": 160 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 160, @@ -871,7 +871,7 @@ "position": 175 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 175, @@ -1092,7 +1092,7 @@ "position": 226 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 226, @@ -1235,7 +1235,7 @@ "position": 253 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 253, @@ -1378,7 +1378,7 @@ "position": 280 }, "quickInfo": { - "kind": "var", + "kind": "enum member", "kindModifiers": "", "textSpan": { "start": 280, diff --git a/tests/cases/compiler/circularInferredTypeOfVariable.ts b/tests/cases/compiler/circularInferredTypeOfVariable.ts new file mode 100644 index 00000000000..662b6bfc8d8 --- /dev/null +++ b/tests/cases/compiler/circularInferredTypeOfVariable.ts @@ -0,0 +1,20 @@ +// @target: es6 + +// Repro from #14428 + +(async () => { + function foo(p: string[]): string[] { + return []; + } + + function bar(p: string[]): string[] { + return []; + } + + let a1: string[] | undefined = []; + + while (true) { + let a2 = foo(a1!); + a1 = await bar(a2); + } +}); \ No newline at end of file diff --git a/tests/cases/compiler/extendsUntypedModule.ts b/tests/cases/compiler/extendsUntypedModule.ts new file mode 100644 index 00000000000..8eaf6b3833a --- /dev/null +++ b/tests/cases/compiler/extendsUntypedModule.ts @@ -0,0 +1,9 @@ +// Test that extending an untyped module is an error, unlike extending unknownSymbol. +// @noImplicitReferences: true + +// @Filename: /node_modules/foo/index.js +This file is not read. + +// @Filename: /a.ts +import Foo from "foo"; +class A extends Foo { } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts index fc0ac400623..4bddfb799f2 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -2,9 +2,17 @@ //// abstract class A { //// private _a: string; -//// -//// abstract get a(): string; -//// abstract set a(newName: string); +//// +//// abstract get a(): number | string; +//// abstract get b(): this; +//// abstract get c(): A; +//// +//// abstract set d(arg: number | string); +//// abstract set e(arg: this); +//// abstract set f(arg: A); +//// +//// abstract get g(): string; +//// abstract set g(newName: string); //// } //// //// // Don't need to add anything in this case. @@ -13,5 +21,11 @@ //// class C extends A {[| |]} verify.rangeAfterCodeFix(` - a: string; + a: string | number; + b: this; + c: A; + d: string | number; + e: this; + f: A; + g: string; `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index a657dfeb718..344a7ee3f2b 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -2,6 +2,7 @@ //// abstract class A { //// abstract f(a: number, b: string): boolean; +//// abstract f(a: number, b: string): this; //// abstract f(a: string, b: number): Function; //// abstract f(a: string): Function; //// } @@ -10,6 +11,7 @@ verify.rangeAfterCodeFix(` f(a: number, b: string): boolean; + f(a: number, b: string): this; f(a: string, b: number): Function; f(a: string): Function; f(a: any, b?: any) { diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts similarity index 50% rename from tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts rename to tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts index e8cb55fa660..55b3ad4b77e 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -1,11 +1,13 @@ -/// - -//// abstract class A { -//// abstract set c(arg: number | string); -//// } -//// -//// class C extends A {[| |]} - -verify.rangeAfterCodeFix(` - c: string | number; -`); \ No newline at end of file +/// + +//// abstract class A { +//// abstract f(): this; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + f(): this { + throw new Error('Method not implemented.'); + } +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 3160a3b9a08..b7300acf5ae 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -2,6 +2,8 @@ //// abstract class A { //// abstract x: number; +//// abstract y: this; +//// abstract z: A; //// abstract foo(): number; //// } //// @@ -10,6 +12,8 @@ verify.rangeAfterCodeFix(` x: number; + y: this; + z: A; foo(): number { throw new Error('Method not implemented.'); } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts similarity index 68% rename from tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts rename to tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts index 8d79cce710e..de128ca1b79 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts @@ -1,11 +1,11 @@ -/// - -//// abstract class A { -//// abstract get b(): number; -//// } -//// -//// class C extends A {[| |]} - -verify.rangeAfterCodeFix(` - b: number; -`); \ No newline at end of file +/// + +//// abstract class A { +//// abstract x: this; +//// } +//// +//// class C extends A {[| |]} + +verify.rangeAfterCodeFix(` + x: this; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts similarity index 71% rename from tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 0ee842975e0..95cc3476bf1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodWithParams.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -1,14 +1,14 @@ /// //// interface I { -//// f(x: number, y: string): I +//// f(x: number, y: this): I //// } //// //// class C implements I {[| //// |]} verify.rangeAfterCodeFix(` -f(x: number,y: string): I { +f(x: number,y: this): I { throw new Error('Method not implemented.'); } `); diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts index 8ab9dbd0131..60707905956 100644 --- a/tests/cases/fourslash/completionInJsDoc.ts +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -2,29 +2,57 @@ // @allowJs: true // @Filename: Foo.js -/////** @/*1*/ */ -////var v1; +//// /** @/*1*/ */ +//// var v1; //// -/////** @p/*2*/ */ -////var v2; +//// /** @p/*2*/ */ +//// var v2; //// -/////** @param /*3*/ */ -////var v3; +//// /** @param /*3*/ */ +//// var v3; //// -/////** @param { n/*4*/ } bar */ -////var v4; +//// /** @param { n/*4*/ } bar */ +//// var v4; //// -/////** @type { n/*5*/ } */ -////var v5; +//// /** @type { n/*5*/ } */ +//// var v5; //// -////// @/*6*/ -////var v6; +//// // @/*6*/ +//// var v6; //// -////// @pa/*7*/ -////var v7; +//// // @pa/*7*/ +//// var v7; //// -/////** @return { n/*8*/ } */ -////var v8; +//// /** @return { n/*8*/ } */ +//// var v8; +//// +//// /** /*9*/ */ +//// +//// /** +//// /*10*/ +//// */ +//// +//// /** +//// * /*11*/ +//// */ +//// +//// /** +//// /*12*/ +//// */ +//// +//// /** +//// * /*13*/ +//// */ +//// +//// /** +//// * some comment /*14*/ +//// */ +//// +//// /** +//// * @param /*15*/ +//// */ +//// +//// /** @param /*16*/ */ goTo.marker('1'); verify.completionListContains("constructor"); @@ -55,3 +83,31 @@ verify.completionListIsEmpty(); goTo.marker('8'); verify.completionListContains('number'); +goTo.marker('9'); +verify.completionListCount(40); +verify.completionListContains("@argument"); + +goTo.marker('10'); +verify.completionListCount(40); +verify.completionListContains("@returns"); + +goTo.marker('11'); +verify.completionListCount(40); +verify.completionListContains("@argument"); + +goTo.marker('12'); +verify.completionListCount(40); +verify.completionListContains("@constructor"); + +goTo.marker('13'); +verify.completionListCount(40); +verify.completionListContains("@param"); + +goTo.marker('14'); +verify.completionListIsEmpty(); + +goTo.marker('15'); +verify.completionListIsEmpty(); + +goTo.marker('16'); +verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListAtInvalidLocations.ts b/tests/cases/fourslash/completionListAtInvalidLocations.ts index 0660f0e183b..171f63825f2 100644 --- a/tests/cases/fourslash/completionListAtInvalidLocations.ts +++ b/tests/cases/fourslash/completionListAtInvalidLocations.ts @@ -1,28 +1,24 @@ /// -////var v1 = ''; -////" /*openString1*/ -////var v2 = ''; -////"/*openString2*/ -////var v3 = ''; -////" bar./*openString3*/ -////var v4 = ''; -////// bar./*inComment1*/ -////var v6 = ''; -////// /*inComment2*/ -////var v7 = ''; -/////** /*inComment3*/ -////var v8 = ''; -/////** /*inComment4*/ **/ -////var v9 = ''; -/////* /*inComment5*/ -////var v11 = ''; -//// // /*inComment6*/ -////var v12 = ''; -////type htm/*inTypeAlias*/ -/// -////// /*inComment7*/ -////foo; -////var v10 = /reg/*inRegExp1*/ex/; +//// var v1 = ''; +//// " /*openString1*/ +//// var v2 = ''; +//// "/*openString2*/ +//// var v3 = ''; +//// " bar./*openString3*/ +//// var v4 = ''; +//// // bar./*inComment1*/ +//// var v6 = ''; +//// // /*inComment2*/ +//// var v7 = ''; +//// /* /*inComment3*/ +//// var v11 = ''; +//// // /*inComment4*/ +//// var v12 = ''; +//// type htm/*inTypeAlias*/ +//// +//// // /*inComment5*/ +//// foo; +//// var v10 = /reg/*inRegExp1*/ex/; goTo.eachMarker(() => verify.completionListIsEmpty()); diff --git a/tests/cases/fourslash/deleteClassWithEnumPresent.ts b/tests/cases/fourslash/deleteClassWithEnumPresent.ts index 8914e0020a0..aaa35272fa9 100644 --- a/tests/cases/fourslash/deleteClassWithEnumPresent.ts +++ b/tests/cases/fourslash/deleteClassWithEnumPresent.ts @@ -16,15 +16,15 @@ verify.navigationTree({ "childItems": [ { "text": "a", - "kind": "const" + "kind": "enum member" }, { "text": "b", - "kind": "const" + "kind": "enum member" }, { "text": "c", - "kind": "const" + "kind": "enum member" } ] } @@ -48,15 +48,15 @@ verify.navigationBar([ "childItems": [ { "text": "a", - "kind": "const" + "kind": "enum member" }, { "text": "b", - "kind": "const" + "kind": "enum member" }, { "text": "c", - "kind": "const" + "kind": "enum member" } ], "indent": 1 diff --git a/tests/cases/fourslash/extendArrayInterfaceMember.ts b/tests/cases/fourslash/extendArrayInterfaceMember.ts index ef3c06b2053..22aeed01f1d 100644 --- a/tests/cases/fourslash/extendArrayInterfaceMember.ts +++ b/tests/cases/fourslash/extendArrayInterfaceMember.ts @@ -10,7 +10,7 @@ verify.numberOfErrorsInCurrentFile(1); // - Supplied parameters do not match any signature of call target. // - Could not select overload for 'call' expression. -verify.quickInfoAt("y", "var y: any"); +verify.quickInfoAt("y", "var y: number"); goTo.eof(); edit.insert("interface Array { pop(def: T): T; }"); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 34afb71ec85..ab83752d93b 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -92,6 +92,7 @@ declare namespace FourSlashInterface { InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterTypeAssertion: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; diff --git a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts index 35dff3af14c..1613b1cb868 100644 --- a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts @@ -36,7 +36,7 @@ verify.navigationTree({ "childItems": [ { "text": "LocalEnumMemberInConstructor", - "kind": "const" + "kind": "enum member" } ] }, @@ -64,7 +64,7 @@ verify.navigationTree({ "childItems": [ { "text": "LocalEnumMemberInMethod", - "kind": "const" + "kind": "enum member" } ] }, @@ -144,7 +144,7 @@ verify.navigationBar([ "childItems": [ { "text": "LocalEnumMemberInConstructor", - "kind": "const" + "kind": "enum member" } ], "indent": 3 @@ -184,7 +184,7 @@ verify.navigationBar([ "childItems": [ { "text": "LocalEnumMemberInMethod", - "kind": "const" + "kind": "enum member" } ], "indent": 3 diff --git a/tests/cases/fourslash/navigationBarItemsItems.ts b/tests/cases/fourslash/navigationBarItemsItems.ts index 69422dd0cc2..4597ac6474b 100644 --- a/tests/cases/fourslash/navigationBarItemsItems.ts +++ b/tests/cases/fourslash/navigationBarItemsItems.ts @@ -130,15 +130,15 @@ verify.navigationTree({ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ] } @@ -263,15 +263,15 @@ verify.navigationBar([ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ], "indent": 2 diff --git a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts index 628fe9c757e..14c7b3caf1c 100644 --- a/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts +++ b/tests/cases/fourslash/quickInfoDisplayPartsEnum1.ts @@ -19,4 +19,4 @@ /////*25*/eInstance1 = /*26*/constE./*27*/e2; /////*28*/eInstance1 = /*29*/constE./*30*/e3; -verify.baselineQuickInfo(); \ No newline at end of file +verify.baselineQuickInfo(); diff --git a/tests/cases/fourslash/server/navbar01.ts b/tests/cases/fourslash/server/navbar01.ts index 4a4f59bcf78..edbfca53afb 100644 --- a/tests/cases/fourslash/server/navbar01.ts +++ b/tests/cases/fourslash/server/navbar01.ts @@ -129,15 +129,15 @@ verify.navigationTree({ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ] } @@ -262,15 +262,15 @@ verify.navigationBar([ "childItems": [ { "text": "value1", - "kind": "const" + "kind": "enum member" }, { "text": "value2", - "kind": "const" + "kind": "enum member" }, { "text": "value3", - "kind": "const" + "kind": "enum member" } ], "indent": 2 diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index 1854010d5b6..433c584e3cf 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -12,7 +12,7 @@ verify.numberOfErrorsInCurrentFile(0); goTo.marker("fooModule"); verify.goToDefinitionIs([]); -verify.quickInfoIs(""); +verify.quickInfoIs("module "); verify.noReferences(); goTo.marker("foo"); diff --git a/tslint.json b/tslint.json index 37f64a05159..5e72aedf065 100644 --- a/tslint.json +++ b/tslint.json @@ -18,7 +18,7 @@ "double", "avoid-escape" ], - "semicolon": [true, "ignore-bound-class-methods"], + "semicolon": [true, "always", "ignore-bound-class-methods"], "whitespace": [true, "check-branch", "check-decl",