diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21b21ed824f1f..952cb7cba6c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ on: branches: - main - release-* + merge_group: + branches: + - main + # - release-* permissions: contents: read @@ -24,43 +28,107 @@ jobs: strategy: fail-fast: false matrix: - os: - - ubuntu-latest - - windows-latest - - macos-latest - node-version: - - '22' - - '20' - - '18' - - '16' - - '14' - bundle: - - 'true' - include: - - node-version: 'lts/*' + config: + # Main builds + - os: ubuntu-latest + node-version: '24' + bundle: true + + # Other builds (skipped in merge queues) + - os: windows-latest + node-version: '24' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + - os: macos-latest + node-version: '24' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + - os: ubuntu-latest + node-version: '22' + bundle: true + - os: windows-latest + node-version: '22' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + # Skip macOS for this version; resources are limited. + # - os: macos-latest + # node-version: '22' + # bundle: true + # skip: ${{ github.event_name == 'merge_group' }} + - os: ubuntu-latest + node-version: '20' + bundle: true + - os: windows-latest + node-version: '20' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + # Skip macOS for this version; resources are limited. + # - os: macos-latest + # node-version: '20' + # bundle: true + # skip: ${{ github.event_name == 'merge_group' }} + - os: ubuntu-latest + node-version: '18' + bundle: true + - os: windows-latest + node-version: '18' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + # Skip macOS for this version; resources are limited. + # - os: macos-latest + # node-version: '18' + # bundle: true + # skip: ${{ github.event_name == 'merge_group' }} + - os: ubuntu-latest + node-version: '16' + bundle: true + - os: windows-latest + node-version: '16' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + - os: macos-latest + node-version: '16' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + - os: ubuntu-latest + node-version: '14' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + - os: windows-latest + node-version: '14' + bundle: true + skip: ${{ github.event_name == 'merge_group' }} + # No Node 14 on ARM macOS + # - os: macos-latest + # node-version: '14' + # bundle: true + # skip: ${{ github.event_name == 'merge_group' }} + + - os: ubuntu-latest + node-version: 'lts/*' bundle: false - os: ubuntu-latest + skip: ${{ github.event_name == 'merge_group' }} + exclude: - # No Node 14 on ARM macOS - - node-version: '14' - os: macos-latest + - config: + skip: true - runs-on: ${{ matrix.os }} - name: Test Node ${{ matrix.node-version }} on ${{ matrix.os }}${{ (!matrix.bundle && ' with --no-bundle') || '' }} + runs-on: ${{ matrix.config.os }} + name: Test Node ${{ matrix.config.node-version }} on ${{ matrix.config.os }}${{ (!matrix.config.bundle && ' with --no-bundle') || '' }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Use node version ${{ matrix.node-version }} + - name: Use node version ${{ matrix.config.node-version }} uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ matrix.config.node-version }} check-latest: true - run: npm ci - name: Tests id: test # run tests, but lint separately - run: npm run test -- --no-lint --bundle=${{ matrix.bundle }} + run: npm run test -- --no-lint --bundle=${{ matrix.config.bundle }} - name: Print baseline diff on failure if: ${{ failure() && steps.test.conclusion == 'failure' }} @@ -70,6 +138,8 @@ jobs: git diff --staged --exit-code coverage: + if: ${{ github.event_name != 'merge_group' }} + runs-on: - 'self-hosted' - '1ES.Pool=TypeScript-1ES-GitHub-Large' @@ -294,6 +364,8 @@ jobs: run: npx hereby build-src --built baselines: + if: ${{ github.event_name != 'merge_group' }} + runs-on: ubuntu-latest steps: @@ -338,3 +410,27 @@ jobs: with: name: fix_baselines.patch path: fix_baselines.patch + + required: + runs-on: ubuntu-latest + if: ${{ always() }} + needs: + - test + - coverage + - lint + - knip + - format + - browser-integration + - typecheck + - smoke + - package-size + - misc + - self-check + - baselines + + steps: + - name: Check required jobs + env: + NEEDS: ${{ toJson(needs) }} + run: | + ! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select((.result == "success" or .result == "skipped") | not)' diff --git a/lib/_tsc.js b/lib/_tsc.js index 11ab5ff444ede..612a1f7eed0fc 100644 --- a/lib/_tsc.js +++ b/lib/_tsc.js @@ -18,7 +18,7 @@ and limitations under the License. // src/compiler/corePublic.ts var versionMajorMinor = "5.9"; -var version = "5.9.2"; +var version = "5.9.3"; // src/compiler/core.ts var emptyArray = []; @@ -20254,10 +20254,22 @@ function createParenthesizerRules(factory2) { } return parenthesizerRule; } + function mixingBinaryOperatorsRequiresParentheses(a, b) { + if (a === 61 /* QuestionQuestionToken */) { + return b === 56 /* AmpersandAmpersandToken */ || b === 57 /* BarBarToken */; + } + if (b === 61 /* QuestionQuestionToken */) { + return a === 56 /* AmpersandAmpersandToken */ || a === 57 /* BarBarToken */; + } + return false; + } function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + const emittedOperand = skipPartiallyEmittedExpressions(operand); + if (isBinaryExpression(emittedOperand) && mixingBinaryOperatorsRequiresParentheses(binaryOperator, emittedOperand.operatorToken.kind)) { + return true; + } const binaryOperatorPrecedence = getOperatorPrecedence(227 /* BinaryExpression */, binaryOperator); const binaryOperatorAssociativity = getOperatorAssociativity(227 /* BinaryExpression */, binaryOperator); - const emittedOperand = skipPartiallyEmittedExpressions(operand); if (!isLeftSideOfBinary && operand.kind === 220 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { return true; } @@ -53296,7 +53308,22 @@ function createTypeChecker(host) { function getPropertyNameNodeForSymbol(symbol, context) { const hashPrivateName = getClonedHashPrivateName(symbol); if (hashPrivateName) { - return hashPrivateName; + const shouldEmitErroneousFieldName = !!context.tracker.reportPrivateInBaseOfClassExpression && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */; + if (!shouldEmitErroneousFieldName) { + return hashPrivateName; + } else { + let rawName2 = unescapeLeadingUnderscores(symbol.escapedName); + rawName2 = rawName2.replace(/__#\d+@#/g, "__#private@#"); + return createPropertyNameNodeForIdentifierOrLiteral( + rawName2, + getEmitScriptTarget(compilerOptions), + /*singleQuote*/ + false, + /*stringNamed*/ + true, + !!(symbol.flags & 8192 /* Method */) + ); + } } const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed); const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed); @@ -124188,10 +124215,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi } const getCommonSourceDirectory3 = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames())); commandLine.fileNames.forEach((fileName) => { - if (isDeclarationFileName(fileName)) return; const path = toPath3(fileName); let outputDts; - if (!fileExtensionIs(fileName, ".json" /* Json */)) { + if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, ".json" /* Json */)) { if (!commandLine.options.outFile) { outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory3); mapOutputFileToResolvedRef.set(toPath3(outputDts), { resolvedRef, source: fileName }); diff --git a/lib/lib.esnext.float16.d.ts b/lib/lib.esnext.float16.d.ts index 7062792dce70d..33bb551633285 100644 --- a/lib/lib.esnext.float16.d.ts +++ b/lib/lib.esnext.float16.d.ts @@ -374,6 +374,8 @@ interface Float16ArrayConstructor { new (length?: number): Float16Array; new (array: ArrayLike | Iterable): Float16Array; new (buffer: TArrayBuffer, byteOffset?: number, length?: number): Float16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float16Array; + new (array: ArrayLike | ArrayBuffer): Float16Array; /** * The size in bytes of each element in the array. diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 87942520f2ab0..2c56042e22d0c 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -5907,7 +5907,6 @@ declare namespace ts { */ interface SourceFileLike { readonly text: string; - languageVariant?: LanguageVariant; } interface SourceFileLike { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; diff --git a/lib/typescript.js b/lib/typescript.js index 2643aa12aa649..0554fc3fc707c 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -2285,7 +2285,7 @@ module.exports = __toCommonJS(typescript_exports); // src/compiler/corePublic.ts var versionMajorMinor = "5.9"; -var version = "5.9.2"; +var version = "5.9.3"; var Comparison = /* @__PURE__ */ ((Comparison3) => { Comparison3[Comparison3["LessThan"] = -1] = "LessThan"; Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo"; @@ -6790,10 +6790,10 @@ var ScriptTarget = /* @__PURE__ */ ((ScriptTarget12) => { ScriptTarget12[ScriptTarget12["Latest"] = 99 /* ESNext */] = "Latest"; return ScriptTarget12; })(ScriptTarget || {}); -var LanguageVariant = /* @__PURE__ */ ((LanguageVariant3) => { - LanguageVariant3[LanguageVariant3["Standard"] = 0] = "Standard"; - LanguageVariant3[LanguageVariant3["JSX"] = 1] = "JSX"; - return LanguageVariant3; +var LanguageVariant = /* @__PURE__ */ ((LanguageVariant4) => { + LanguageVariant4[LanguageVariant4["Standard"] = 0] = "Standard"; + LanguageVariant4[LanguageVariant4["JSX"] = 1] = "JSX"; + return LanguageVariant4; })(LanguageVariant || {}); var WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags3) => { WatchDirectoryFlags3[WatchDirectoryFlags3["None"] = 0] = "None"; @@ -24351,10 +24351,22 @@ function createParenthesizerRules(factory2) { } return parenthesizerRule; } + function mixingBinaryOperatorsRequiresParentheses(a, b) { + if (a === 61 /* QuestionQuestionToken */) { + return b === 56 /* AmpersandAmpersandToken */ || b === 57 /* BarBarToken */; + } + if (b === 61 /* QuestionQuestionToken */) { + return a === 56 /* AmpersandAmpersandToken */ || a === 57 /* BarBarToken */; + } + return false; + } function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + const emittedOperand = skipPartiallyEmittedExpressions(operand); + if (isBinaryExpression(emittedOperand) && mixingBinaryOperatorsRequiresParentheses(binaryOperator, emittedOperand.operatorToken.kind)) { + return true; + } const binaryOperatorPrecedence = getOperatorPrecedence(227 /* BinaryExpression */, binaryOperator); const binaryOperatorAssociativity = getOperatorAssociativity(227 /* BinaryExpression */, binaryOperator); - const emittedOperand = skipPartiallyEmittedExpressions(operand); if (!isLeftSideOfBinary && operand.kind === 220 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { return true; } @@ -57907,7 +57919,22 @@ function createTypeChecker(host) { function getPropertyNameNodeForSymbol(symbol, context) { const hashPrivateName = getClonedHashPrivateName(symbol); if (hashPrivateName) { - return hashPrivateName; + const shouldEmitErroneousFieldName = !!context.tracker.reportPrivateInBaseOfClassExpression && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */; + if (!shouldEmitErroneousFieldName) { + return hashPrivateName; + } else { + let rawName2 = unescapeLeadingUnderscores(symbol.escapedName); + rawName2 = rawName2.replace(/__#\d+@#/g, "__#private@#"); + return createPropertyNameNodeForIdentifierOrLiteral( + rawName2, + getEmitScriptTarget(compilerOptions), + /*singleQuote*/ + false, + /*stringNamed*/ + true, + !!(symbol.flags & 8192 /* Method */) + ); + } } const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed); const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed); @@ -129038,10 +129065,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi } const getCommonSourceDirectory3 = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames())); commandLine.fileNames.forEach((fileName) => { - if (isDeclarationFileName(fileName)) return; const path = toPath3(fileName); let outputDts; - if (!fileExtensionIs(fileName, ".json" /* Json */)) { + if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, ".json" /* Json */)) { if (!commandLine.options.outFile) { outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory3); mapOutputFileToResolvedRef.set(toPath3(outputDts), { resolvedRef, source: fileName }); @@ -140403,7 +140429,7 @@ function isInsideJsxElementOrAttribute(sourceFile, position) { if (token && token.kind === 20 /* CloseBraceToken */ && token.parent.kind === 295 /* JsxExpression */) { return true; } - if (token.kind === 31 /* LessThanSlashToken */ && token.parent.kind === 288 /* JsxClosingElement */) { + if (token.kind === 30 /* LessThanToken */ && token.parent.kind === 288 /* JsxClosingElement */) { return true; } return false; @@ -140431,7 +140457,7 @@ function isInJSXText(sourceFile, position) { function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 286 /* JsxSelfClosingElement */ && node.kind <= 295 /* JsxExpression */ || node.kind === 12 /* JsxText */ || node.kind === 30 /* LessThanToken */ || node.kind === 32 /* GreaterThanToken */ || node.kind === 80 /* Identifier */ || node.kind === 20 /* CloseBraceToken */ || node.kind === 19 /* OpenBraceToken */ || node.kind === 44 /* SlashToken */ || node.kind === 31 /* LessThanSlashToken */) { + if (node.kind >= 286 /* JsxSelfClosingElement */ && node.kind <= 295 /* JsxExpression */ || node.kind === 12 /* JsxText */ || node.kind === 30 /* LessThanToken */ || node.kind === 32 /* GreaterThanToken */ || node.kind === 80 /* Identifier */ || node.kind === 20 /* CloseBraceToken */ || node.kind === 19 /* OpenBraceToken */ || node.kind === 44 /* SlashToken */) { node = node.parent; } else if (node.kind === 285 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; @@ -151873,9 +151899,7 @@ function createChildren(node, sourceFile) { }); return children; } - const languageVariant = (sourceFile == null ? void 0 : sourceFile.languageVariant) ?? 0 /* Standard */; scanner.setText((sourceFile || node.getSourceFile()).text); - scanner.setLanguageVariant(languageVariant); let pos = node.pos; const processNode = (child) => { addSyntheticNodes(children, pos, child.pos, node); @@ -151892,7 +151916,6 @@ function createChildren(node, sourceFile) { node.forEachChild(processNode, processNodes); addSyntheticNodes(children, pos, node.end, node); scanner.setText(void 0); - scanner.setLanguageVariant(0 /* Standard */); return children; } function addSyntheticNodes(nodes, pos, end, parent2) { @@ -167606,7 +167629,7 @@ function getJsxClosingTagCompletion(location, sourceFile) { switch (node.kind) { case 288 /* JsxClosingElement */: return true; - case 31 /* LessThanSlashToken */: + case 44 /* SlashToken */: case 32 /* GreaterThanToken */: case 80 /* Identifier */: case 212 /* PropertyAccessExpression */: @@ -168942,7 +168965,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position, location = currentToken; } break; - case 31 /* LessThanSlashToken */: + case 44 /* SlashToken */: if (currentToken.parent.kind === 286 /* JsxSelfClosingElement */) { location = currentToken; } @@ -168951,7 +168974,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position, } switch (parent2.kind) { case 288 /* JsxClosingElement */: - if (contextToken.kind === 31 /* LessThanSlashToken */) { + if (contextToken.kind === 44 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } @@ -170572,7 +170595,7 @@ function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) { case "<": return !!contextToken && contextToken.kind === 30 /* LessThanToken */ && (!isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": - return !!contextToken && (isStringLiteralLike(contextToken) ? !!tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 31 /* LessThanSlashToken */ && isJsxClosingElement(contextToken.parent)); + return !!contextToken && (isStringLiteralLike(contextToken) ? !!tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 44 /* SlashToken */ && isJsxClosingElement(contextToken.parent)); case " ": return !!contextToken && isImportKeyword(contextToken) && contextToken.parent.kind === 308 /* SourceFile */; default: diff --git a/package-lock.json b/package-lock.json index 14fa0eca972f5..53fc39177b439 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "typescript", - "version": "5.9.2", + "version": "5.9.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "typescript", - "version": "5.9.2", + "version": "5.9.3", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 22a9e79564f5f..f7f35370bc8ad 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "5.9.2", + "version": "5.9.3", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 77f35376da785..aac52abfc4dd4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8908,7 +8908,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getPropertyNameNodeForSymbol(symbol: Symbol, context: NodeBuilderContext) { const hashPrivateName = getClonedHashPrivateName(symbol); if (hashPrivateName) { - return hashPrivateName; + const shouldEmitErroneousFieldName = !!context.tracker.reportPrivateInBaseOfClassExpression && + context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral; + if (!shouldEmitErroneousFieldName) { + return hashPrivateName; + } + else { + let rawName = unescapeLeadingUnderscores(symbol.escapedName); + // symbol IDs are unstable - replace #nnn# with #private# + rawName = rawName.replace(/__#\d+@#/g, "__#private@#"); + return createPropertyNameNodeForIdentifierOrLiteral(rawName, getEmitScriptTarget(compilerOptions), /*singleQuote*/ false, /*stringNamed*/ true, !!(symbol.flags & SymbolFlags.Method)); + } } const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed); const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed); diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 9c1447c9c6fd5..23888726d280e 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ export const versionMajorMinor = "5.9"; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ -export const version = "5.9.2" as string; +export const version = "5.9.3" as string; /** * Type of objects whose values are all of the same type. diff --git a/src/compiler/factory/parenthesizerRules.ts b/src/compiler/factory/parenthesizerRules.ts index 3a67604847438..58284decd437a 100644 --- a/src/compiler/factory/parenthesizerRules.ts +++ b/src/compiler/factory/parenthesizerRules.ts @@ -112,6 +112,16 @@ export function createParenthesizerRules(factory: NodeFactory): ParenthesizerRul return parenthesizerRule; } + function mixingBinaryOperatorsRequiresParentheses(a: SyntaxKind, b: SyntaxKind) { + if (a === SyntaxKind.QuestionQuestionToken) { + return b === SyntaxKind.AmpersandAmpersandToken || b === SyntaxKind.BarBarToken; + } + if (b === SyntaxKind.QuestionQuestionToken) { + return a === SyntaxKind.AmpersandAmpersandToken || a === SyntaxKind.BarBarToken; + } + return false; + } + /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -121,6 +131,10 @@ export function createParenthesizerRules(factory: NodeFactory): ParenthesizerRul * BinaryExpression. */ function binaryOperandNeedsParentheses(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand: Expression | undefined) { + const emittedOperand = skipPartiallyEmittedExpressions(operand); + if (isBinaryExpression(emittedOperand) && mixingBinaryOperatorsRequiresParentheses(binaryOperator, emittedOperand.operatorToken.kind)) { + return true; + } // If the operand has lower precedence, then it needs to be parenthesized to preserve the // intent of the expression. For example, if the operand is `a + b` and the operator is // `*`, then we need to parenthesize the operand to preserve the intended order of @@ -140,7 +154,6 @@ export function createParenthesizerRules(factory: NodeFactory): ParenthesizerRul // the intended order of operations: `(a ** b) ** c` const binaryOperatorPrecedence = getOperatorPrecedence(SyntaxKind.BinaryExpression, binaryOperator); const binaryOperatorAssociativity = getOperatorAssociativity(SyntaxKind.BinaryExpression, binaryOperator); - const emittedOperand = skipPartiallyEmittedExpressions(operand); if (!isLeftSideOfBinary && operand.kind === SyntaxKind.ArrowFunction && binaryOperatorPrecedence > OperatorPrecedence.Assignment) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 445946dab0c67..560b9e2c5d61a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4083,10 +4083,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro } const getCommonSourceDirectory = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames())); commandLine.fileNames.forEach(fileName => { - if (isDeclarationFileName(fileName)) return; const path = toPath(fileName); let outputDts; - if (!fileExtensionIs(fileName, Extension.Json)) { + if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, Extension.Json)) { if (!commandLine.options.outFile) { outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory); mapOutputFileToResolvedRef!.set(toPath(outputDts), { resolvedRef, source: fileName }); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1cfe3e04ba68d..ee7f4338a3a10 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4288,7 +4288,6 @@ export interface SourceFileLike { lineMap?: readonly number[]; /** @internal */ getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number; - languageVariant?: LanguageVariant; } /** @internal */ diff --git a/src/lib/esnext.float16.d.ts b/src/lib/esnext.float16.d.ts index 88b12f6753605..6a1f600040d75 100644 --- a/src/lib/esnext.float16.d.ts +++ b/src/lib/esnext.float16.d.ts @@ -356,6 +356,8 @@ interface Float16ArrayConstructor { new (length?: number): Float16Array; new (array: ArrayLike | Iterable): Float16Array; new (buffer: TArrayBuffer, byteOffset?: number, length?: number): Float16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float16Array; + new (array: ArrayLike | ArrayBuffer): Float16Array; /** * The size in bytes of each element in the array. diff --git a/src/services/completions.ts b/src/services/completions.ts index dc01ea8ede4b9..fb3dbe44db260 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1595,7 +1595,7 @@ function getJsxClosingTagCompletion(location: Node | undefined, sourceFile: Sour switch (node.kind) { case SyntaxKind.JsxClosingElement: return true; - case SyntaxKind.LessThanSlashToken: + case SyntaxKind.SlashToken: case SyntaxKind.GreaterThanToken: case SyntaxKind.Identifier: case SyntaxKind.PropertyAccessExpression: @@ -3508,7 +3508,7 @@ function getCompletionData( } break; - case SyntaxKind.LessThanSlashToken: + case SyntaxKind.SlashToken: if (currentToken.parent.kind === SyntaxKind.JsxSelfClosingElement) { location = currentToken; } @@ -3518,7 +3518,7 @@ function getCompletionData( switch (parent.kind) { case SyntaxKind.JsxClosingElement: - if (contextToken.kind === SyntaxKind.LessThanSlashToken) { + if (contextToken.kind === SyntaxKind.SlashToken) { isStartingCloseTag = true; location = contextToken; } @@ -5809,7 +5809,7 @@ function isValidTrigger(sourceFile: SourceFile, triggerCharacter: CompletionsTri case "/": return !!contextToken && (isStringLiteralLike(contextToken) ? !!tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === SyntaxKind.LessThanSlashToken && isJsxClosingElement(contextToken.parent)); + : contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent)); case " ": return !!contextToken && isImportKeyword(contextToken) && contextToken.parent.kind === SyntaxKind.SourceFile; default: diff --git a/src/services/services.ts b/src/services/services.ts index 2df3b75ae6cb7..4849749a0656b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -504,9 +504,8 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea }); return children; } - const languageVariant = sourceFile?.languageVariant ?? LanguageVariant.Standard; + scanner.setText((sourceFile || node.getSourceFile()).text); - scanner.setLanguageVariant(languageVariant); let pos = node.pos; const processNode = (child: Node) => { addSyntheticNodes(children, pos, child.pos, node); @@ -527,7 +526,6 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea node.forEachChild(processNode, processNodes); addSyntheticNodes(children, pos, node.end, node); scanner.setText(undefined); - scanner.setLanguageVariant(LanguageVariant.Standard); return children; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ceb56323ceeb6..bec7d4b266d20 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1889,7 +1889,7 @@ export function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: } //
|
- if (token.kind === SyntaxKind.LessThanSlashToken && token.parent.kind === SyntaxKind.JsxClosingElement) { + if (token.kind === SyntaxKind.LessThanToken && token.parent.kind === SyntaxKind.JsxClosingElement) { return true; } @@ -1934,7 +1934,6 @@ export function isInsideJsxElement(sourceFile: SourceFile, position: number): bo || node.kind === SyntaxKind.CloseBraceToken || node.kind === SyntaxKind.OpenBraceToken || node.kind === SyntaxKind.SlashToken - || node.kind === SyntaxKind.LessThanSlashToken ) { node = node.parent; } diff --git a/src/testRunner/unittests/printer.ts b/src/testRunner/unittests/printer.ts index ab6dd5a718415..eac7ed1cdac4f 100644 --- a/src/testRunner/unittests/printer.ts +++ b/src/testRunner/unittests/printer.ts @@ -423,5 +423,311 @@ describe("unittests:: PrinterAPI", () => { ), ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), )); + + printsCorrectly("binaryBarBarExpressionWithLeftBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.BarBarToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryAmpersandAmpersandExpressionWithLeftBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryBarBarExpressionWithRightBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.BarBarToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryAmpersandAmpersandExpressionWithRightBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithLeftBinaryBarBarExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.BarBarToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithLeftBinaryAmpersandAmpersandExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithRightBinaryBarBarExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.BarBarToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithRightBinaryAmpersandAmpersandExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithLeftBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithRightBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryCommaExpressionWithLeftBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.CommaToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryCommaExpressionWithRightBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.CommaToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryEqualsEqualsExpressionWithLeftBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.EqualsEqualsToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryEqualsEqualsExpressionWithRightBinaryQuestionQuestionExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.EqualsEqualsToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithLeftBinaryCommaExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.CommaToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithRightBinaryCommaExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.CommaToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithLeftBinaryEqualsEqualsExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.EqualsEqualsToken), + ts.factory.createIdentifier("b"), + ), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createIdentifier("c"), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); + + printsCorrectly("binaryQuestionQuestionExpressionWithRightBinaryEqualsEqualsExpression", {}, printer => + printer.printNode( + ts.EmitHint.Unspecified, + ts.factory.createExpressionStatement( + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("a"), + ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), + ts.factory.createBinaryExpression( + ts.factory.createIdentifier("b"), + ts.factory.createToken(ts.SyntaxKind.EqualsEqualsToken), + ts.factory.createIdentifier("c"), + ), + ), + ), + ts.createSourceFile("source.ts", "", ts.ScriptTarget.ESNext), + )); }); }); diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index c8f8f3d9143c7..0d5d1f5310121 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -91,6 +91,68 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio }), commandLineArgs: ["-b", "packages/pkg1.tsconfig.json", "packages/pkg2.tsconfig.json", "--verbose", "--traceResolution"], }); + + verifyTsc({ + scenario: "moduleResolution", + subScenario: "resolution from d.ts of referenced project", + sys: () => + TestServerHost.createWatchedSystem({ + "/home/src/workspaces/project/common.d.ts": "export type OnValue = (value: number) => void", + "/home/src/workspaces/project/producer/index.ts": dedent` + export { ValueProducerDeclaration } from "./in-js" + import { OnValue } from "@common" + export interface ValueProducerFromTs { + onValue: OnValue; + } + `, + "/home/src/workspaces/project/producer/in-js.d.ts": dedent` + import { OnValue } from "@common" + export interface ValueProducerDeclaration { + onValue: OnValue; + } + `, + "/home/src/workspaces/project/producer/tsconfig.json": jsonToReadableText({ + compilerOptions: { + strict: true, + composite: true, + module: "nodenext", + moduleResolution: "nodenext", + paths: { + "@common": ["../common.d.ts"], + }, + libReplacement: false, + }, + }), + "/home/src/workspaces/project/consumer/index.ts": dedent` + import { ValueProducerDeclaration, ValueProducerFromTs } from "@producer" + declare let v: ValueProducerDeclaration; + // n is implicitly any because onValue is actually any (despite what the tooltip says) + v.onValue = (n) => { + + } + + // n is implicitly number as expected + declare let v2: ValueProducerFromTs; + v2.onValue = (n) => { + + }`, + "/home/src/workspaces/project/consumer/tsconfig.json": jsonToReadableText({ + compilerOptions: { + strict: true, + module: "nodenext", + moduleResolution: "nodenext", + paths: { + "@producer": ["../producer/index"], + }, + libReplacement: false, + }, + references: [ + { path: "../producer" }, + ], + }), + }), + commandLineArgs: ["--b", "consumer", "--traceResolution", "-v"], + }); }); describe("unittests:: tsbuild:: moduleResolution:: impliedNodeFormat differs between projects for shared file", () => { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 87942520f2ab0..2c56042e22d0c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5907,7 +5907,6 @@ declare namespace ts { */ interface SourceFileLike { readonly text: string; - languageVariant?: LanguageVariant; } interface SourceFileLike { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithLeftBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithLeftBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..c4a864cada86e --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithLeftBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +(a ?? b) && c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithRightBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithRightBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..631477f80824e --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryAmpersandAmpersandExpressionWithRightBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a && (b ?? c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithLeftBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithLeftBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..affbdb4c02740 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithLeftBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +(a ?? b) || c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithRightBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithRightBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..b3a9c2774d7c2 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryBarBarExpressionWithRightBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a || (b ?? c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithLeftBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithLeftBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..89168051f6b45 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithLeftBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a ?? b, c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithRightBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithRightBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..71d5273feedcb --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryCommaExpressionWithRightBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a, b ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithLeftBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithLeftBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..76b39c1d7695e --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithLeftBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +(a ?? b) == c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithRightBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithRightBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..6f583e8aa54e1 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryEqualsEqualsExpressionWithRightBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a == (b ?? c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryAmpersandAmpersandExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryAmpersandAmpersandExpression.js new file mode 100644 index 0000000000000..12debb34d1514 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryAmpersandAmpersandExpression.js @@ -0,0 +1 @@ +(a && b) ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryBarBarExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryBarBarExpression.js new file mode 100644 index 0000000000000..de158d5222234 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryBarBarExpression.js @@ -0,0 +1 @@ +(a || b) ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryCommaExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryCommaExpression.js new file mode 100644 index 0000000000000..a8723f46e8f27 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryCommaExpression.js @@ -0,0 +1 @@ +(a, b) ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryEqualsEqualsExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryEqualsEqualsExpression.js new file mode 100644 index 0000000000000..334c6bc06248e --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryEqualsEqualsExpression.js @@ -0,0 +1 @@ +a == b ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..b9b28fee1f731 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithLeftBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a ?? b ?? c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryAmpersandAmpersandExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryAmpersandAmpersandExpression.js new file mode 100644 index 0000000000000..5bcfab5819a7c --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryAmpersandAmpersandExpression.js @@ -0,0 +1 @@ +a ?? (b && c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryBarBarExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryBarBarExpression.js new file mode 100644 index 0000000000000..23e450ccd66e0 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryBarBarExpression.js @@ -0,0 +1 @@ +a ?? (b || c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryCommaExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryCommaExpression.js new file mode 100644 index 0000000000000..ab0bf02288177 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryCommaExpression.js @@ -0,0 +1 @@ +a ?? (b, c); \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryEqualsEqualsExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryEqualsEqualsExpression.js new file mode 100644 index 0000000000000..7cb8388a2a87b --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryEqualsEqualsExpression.js @@ -0,0 +1 @@ +a ?? b == c; \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryQuestionQuestionExpression.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryQuestionQuestionExpression.js new file mode 100644 index 0000000000000..226fddaf8033d --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.binaryQuestionQuestionExpressionWithRightBinaryQuestionQuestionExpression.js @@ -0,0 +1 @@ +a ?? (b ?? c); \ No newline at end of file diff --git a/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.js b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.js new file mode 100644 index 0000000000000..d6156b1c31fc3 --- /dev/null +++ b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.js @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts] //// + +//// [privateFieldsInClassExpressionDeclaration.ts] +export const ClassExpression = class { + #context = 0; + #method() { return 42; } + public value = 1; +}; + +// Additional test with static private fields +export const ClassExpressionStatic = class { + static #staticPrivate = "hidden"; + #instancePrivate = true; + public exposed = "visible"; +}; + +//// [privateFieldsInClassExpressionDeclaration.js] +var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; +var _instances, _context, _method, _a, _b, _ClassExpressionStatic_staticPrivate, _ClassExpressionStatic_instancePrivate; +export const ClassExpression = (_a = class { + constructor() { + _instances.add(this); + _context.set(this, 0); + this.value = 1; + } + }, + _context = new WeakMap(), + _instances = new WeakSet(), + _method = function _method() { return 42; }, + _a); +// Additional test with static private fields +export const ClassExpressionStatic = (_b = class { + constructor() { + _ClassExpressionStatic_instancePrivate.set(this, true); + this.exposed = "visible"; + } + }, + _ClassExpressionStatic_instancePrivate = new WeakMap(), + __setFunctionName(_b, "ClassExpressionStatic"), + _ClassExpressionStatic_staticPrivate = { value: "hidden" }, + _b); + + +//// [privateFieldsInClassExpressionDeclaration.d.ts] +export declare const ClassExpression: { + new (): { + "__#private@#context": number; + "__#private@#method"(): number; + value: number; + }; +}; +export declare const ClassExpressionStatic: { + new (): { + "__#private@#instancePrivate": boolean; + exposed: string; + }; + "__#private@#staticPrivate": string; +}; diff --git a/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.symbols b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.symbols new file mode 100644 index 0000000000000..395e587de77bd --- /dev/null +++ b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts] //// + +=== privateFieldsInClassExpressionDeclaration.ts === +export const ClassExpression = class { +>ClassExpression : Symbol(ClassExpression, Decl(privateFieldsInClassExpressionDeclaration.ts, 0, 12)) + + #context = 0; +>#context : Symbol(ClassExpression.#context, Decl(privateFieldsInClassExpressionDeclaration.ts, 0, 38)) + + #method() { return 42; } +>#method : Symbol(ClassExpression.#method, Decl(privateFieldsInClassExpressionDeclaration.ts, 1, 17)) + + public value = 1; +>value : Symbol(ClassExpression.value, Decl(privateFieldsInClassExpressionDeclaration.ts, 2, 28)) + +}; + +// Additional test with static private fields +export const ClassExpressionStatic = class { +>ClassExpressionStatic : Symbol(ClassExpressionStatic, Decl(privateFieldsInClassExpressionDeclaration.ts, 7, 12)) + + static #staticPrivate = "hidden"; +>#staticPrivate : Symbol(ClassExpressionStatic.#staticPrivate, Decl(privateFieldsInClassExpressionDeclaration.ts, 7, 44)) + + #instancePrivate = true; +>#instancePrivate : Symbol(ClassExpressionStatic.#instancePrivate, Decl(privateFieldsInClassExpressionDeclaration.ts, 8, 37)) + + public exposed = "visible"; +>exposed : Symbol(ClassExpressionStatic.exposed, Decl(privateFieldsInClassExpressionDeclaration.ts, 9, 28)) + +}; diff --git a/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.types b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.types new file mode 100644 index 0000000000000..2377b1ba09167 --- /dev/null +++ b/tests/baselines/reference/privateFieldsInClassExpressionDeclaration.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts] //// + +=== privateFieldsInClassExpressionDeclaration.ts === +export const ClassExpression = class { +>ClassExpression : typeof ClassExpression +> : ^^^^^^^^^^^^^^^^^^^^^^ +>class { #context = 0; #method() { return 42; } public value = 1;} : typeof ClassExpression +> : ^^^^^^^^^^^^^^^^^^^^^^ + + #context = 0; +>#context : number +> : ^^^^^^ +>0 : 0 +> : ^ + + #method() { return 42; } +>#method : () => number +> : ^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + public value = 1; +>value : number +> : ^^^^^^ +>1 : 1 +> : ^ + +}; + +// Additional test with static private fields +export const ClassExpressionStatic = class { +>ClassExpressionStatic : typeof ClassExpressionStatic +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>class { static #staticPrivate = "hidden"; #instancePrivate = true; public exposed = "visible";} : typeof ClassExpressionStatic +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + static #staticPrivate = "hidden"; +>#staticPrivate : string +> : ^^^^^^ +>"hidden" : "hidden" +> : ^^^^^^^^ + + #instancePrivate = true; +>#instancePrivate : boolean +> : ^^^^^^^ +>true : true +> : ^^^^ + + public exposed = "visible"; +>exposed : string +> : ^^^^^^ +>"visible" : "visible" +> : ^^^^^^^^^ + +}; diff --git a/tests/baselines/reference/tsbuild/moduleResolution/resolution-from-d.ts-of-referenced-project.js b/tests/baselines/reference/tsbuild/moduleResolution/resolution-from-d.ts-of-referenced-project.js new file mode 100644 index 0000000000000..99d56c4fa8f54 --- /dev/null +++ b/tests/baselines/reference/tsbuild/moduleResolution/resolution-from-d.ts-of-referenced-project.js @@ -0,0 +1,323 @@ +currentDirectory:: /home/src/workspaces/project useCaseSensitiveFileNames:: false +Input:: +//// [/home/src/workspaces/project/common.d.ts] +export type OnValue = (value: number) => void + +//// [/home/src/workspaces/project/producer/index.ts] +export { ValueProducerDeclaration } from "./in-js" +import { OnValue } from "@common" +export interface ValueProducerFromTs { + onValue: OnValue; +} + + +//// [/home/src/workspaces/project/producer/in-js.d.ts] +import { OnValue } from "@common" +export interface ValueProducerDeclaration { + onValue: OnValue; +} + + +//// [/home/src/workspaces/project/producer/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "composite": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "paths": { + "@common": [ + "../common.d.ts" + ] + }, + "libReplacement": false + } +} + +//// [/home/src/workspaces/project/consumer/index.ts] +import { ValueProducerDeclaration, ValueProducerFromTs } from "@producer" +declare let v: ValueProducerDeclaration; +// n is implicitly any because onValue is actually any (despite what the tooltip says) +v.onValue = (n) => { + +} + +// n is implicitly number as expected +declare let v2: ValueProducerFromTs; +v2.onValue = (n) => { + +} + +//// [/home/src/workspaces/project/consumer/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "paths": { + "@producer": [ + "../producer/index" + ] + }, + "libReplacement": false + }, + "references": [ + { + "path": "../producer" + } + ] +} + +//// [/home/src/tslibs/TS/Lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + + +/home/src/tslibs/TS/Lib/tsc.js --b consumer --traceResolution -v +Output:: +[HH:MM:SS AM] Projects in this build: + * producer/tsconfig.json + * consumer/tsconfig.json + +[HH:MM:SS AM] Project 'producer/tsconfig.json' is out of date because output file 'producer/tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/home/src/workspaces/project/producer/tsconfig.json'... + +File '/home/src/workspaces/project/producer/package.json' does not exist. +File '/home/src/workspaces/project/package.json' does not exist. +File '/home/src/workspaces/package.json' does not exist. +File '/home/src/package.json' does not exist. +File '/home/package.json' does not exist. +File '/package.json' does not exist. +======== Resolving module '@common' from '/home/src/workspaces/project/producer/in-js.d.ts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +'paths' option is specified, looking for a pattern to match module name '@common'. +Module name '@common', matched pattern '@common'. +Trying substitution '../common.d.ts', candidate module location: '../common.d.ts'. +File '/home/src/workspaces/project/common.d.ts' exists - use it as a name resolution result. +======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ======== +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/project/producer/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +======== Resolving module './in-js' from '/home/src/workspaces/project/producer/index.ts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +Loading module as file / folder, candidate module location '/home/src/workspaces/project/producer/in-js', target file types: TypeScript, JavaScript, Declaration, JSON. +File '/home/src/workspaces/project/producer/in-js.ts' does not exist. +File '/home/src/workspaces/project/producer/in-js.tsx' does not exist. +File '/home/src/workspaces/project/producer/in-js.d.ts' exists - use it as a name resolution result. +======== Module name './in-js' was successfully resolved to '/home/src/workspaces/project/producer/in-js.d.ts'. ======== +======== Resolving module '@common' from '/home/src/workspaces/project/producer/index.ts'. ======== +Resolution for module '@common' was found in cache from location '/home/src/workspaces/project/producer'. +======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ======== +File '/home/src/tslibs/TS/Lib/package.json' does not exist. +File '/home/src/tslibs/TS/package.json' does not exist. +File '/home/src/tslibs/package.json' does not exist. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +[HH:MM:SS AM] Project 'consumer/tsconfig.json' is out of date because output file 'consumer/tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/home/src/workspaces/project/consumer/tsconfig.json'... + +File '/home/src/workspaces/project/consumer/package.json' does not exist. +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +======== Resolving module '@producer' from '/home/src/workspaces/project/consumer/index.ts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +'paths' option is specified, looking for a pattern to match module name '@producer'. +Module name '@producer', matched pattern '@producer'. +Trying substitution '../producer/index', candidate module location: '../producer/index'. +Loading module as file / folder, candidate module location '/home/src/workspaces/project/producer/index', target file types: TypeScript, JavaScript, Declaration, JSON. +File '/home/src/workspaces/project/producer/index.ts' exists - use it as a name resolution result. +======== Module name '@producer' was successfully resolved to '/home/src/workspaces/project/producer/index.ts'. ======== +File '/home/src/workspaces/project/producer/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +======== Resolving module './in-js' from '/home/src/workspaces/project/producer/index.ts'. ======== +Using compiler options of project reference redirect '/home/src/workspaces/project/producer/tsconfig.json'. +Resolution for module './in-js' was found in cache from location '/home/src/workspaces/project/producer'. +======== Module name './in-js' was successfully resolved to '/home/src/workspaces/project/producer/in-js.d.ts'. ======== +======== Resolving module '@common' from '/home/src/workspaces/project/producer/index.ts'. ======== +Using compiler options of project reference redirect '/home/src/workspaces/project/producer/tsconfig.json'. +Resolution for module '@common' was found in cache from location '/home/src/workspaces/project/producer'. +======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ======== +File '/home/src/workspaces/project/producer/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +======== Resolving module '@common' from '/home/src/workspaces/project/producer/in-js.d.ts'. ======== +Using compiler options of project reference redirect '/home/src/workspaces/project/producer/tsconfig.json'. +Resolution for module '@common' was found in cache from location '/home/src/workspaces/project/producer'. +======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ======== +File '/home/src/workspaces/project/package.json' does not exist according to earlier cached lookups. +File '/home/src/workspaces/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +File '/home/src/tslibs/TS/Lib/package.json' does not exist according to earlier cached lookups. +File '/home/src/tslibs/TS/package.json' does not exist according to earlier cached lookups. +File '/home/src/tslibs/package.json' does not exist according to earlier cached lookups. +File '/home/src/package.json' does not exist according to earlier cached lookups. +File '/home/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. + + +//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib* + +//// [/home/src/workspaces/project/producer/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [/home/src/workspaces/project/producer/index.d.ts] +export { ValueProducerDeclaration } from "./in-js"; +import { OnValue } from "@common"; +export interface ValueProducerFromTs { + onValue: OnValue; +} + + +//// [/home/src/workspaces/project/producer/tsconfig.tsbuildinfo] +{"fileNames":["../../../tslibs/ts/lib/lib.esnext.full.d.ts","../common.d.ts","./in-js.d.ts","./index.ts"],"fileIdsList":[[2],[2,3]],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedFormat":1},{"version":"3658943742-export type OnValue = (value: number) => void","impliedFormat":1},{"version":"13199476566-import { OnValue } from \"@common\"\nexport interface ValueProducerDeclaration {\n onValue: OnValue;\n}\n","impliedFormat":1},{"version":"-18594017076-export { ValueProducerDeclaration } from \"./in-js\"\nimport { OnValue } from \"@common\"\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n","signature":"304566626-export { ValueProducerDeclaration } from \"./in-js\";\nimport { OnValue } from \"@common\";\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n","impliedFormat":1}],"root":[3,4],"options":{"composite":true,"module":199,"strict":true},"referencedMap":[[3,1],[4,2]],"latestChangedDtsFile":"./index.d.ts","version":"FakeTSVersion"} + +//// [/home/src/workspaces/project/producer/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../../tslibs/ts/lib/lib.esnext.full.d.ts", + "../common.d.ts", + "./in-js.d.ts", + "./index.ts" + ], + "fileIdsList": [ + [ + "../common.d.ts" + ], + [ + "../common.d.ts", + "./in-js.d.ts" + ] + ], + "fileInfos": { + "../../../tslibs/ts/lib/lib.esnext.full.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedFormat": 1 + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedFormat": "commonjs" + }, + "../common.d.ts": { + "original": { + "version": "3658943742-export type OnValue = (value: number) => void", + "impliedFormat": 1 + }, + "version": "3658943742-export type OnValue = (value: number) => void", + "signature": "3658943742-export type OnValue = (value: number) => void", + "impliedFormat": "commonjs" + }, + "./in-js.d.ts": { + "original": { + "version": "13199476566-import { OnValue } from \"@common\"\nexport interface ValueProducerDeclaration {\n onValue: OnValue;\n}\n", + "impliedFormat": 1 + }, + "version": "13199476566-import { OnValue } from \"@common\"\nexport interface ValueProducerDeclaration {\n onValue: OnValue;\n}\n", + "signature": "13199476566-import { OnValue } from \"@common\"\nexport interface ValueProducerDeclaration {\n onValue: OnValue;\n}\n", + "impliedFormat": "commonjs" + }, + "./index.ts": { + "original": { + "version": "-18594017076-export { ValueProducerDeclaration } from \"./in-js\"\nimport { OnValue } from \"@common\"\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n", + "signature": "304566626-export { ValueProducerDeclaration } from \"./in-js\";\nimport { OnValue } from \"@common\";\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n", + "impliedFormat": 1 + }, + "version": "-18594017076-export { ValueProducerDeclaration } from \"./in-js\"\nimport { OnValue } from \"@common\"\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n", + "signature": "304566626-export { ValueProducerDeclaration } from \"./in-js\";\nimport { OnValue } from \"@common\";\nexport interface ValueProducerFromTs {\n onValue: OnValue;\n}\n", + "impliedFormat": "commonjs" + } + }, + "root": [ + [ + 3, + "./in-js.d.ts" + ], + [ + 4, + "./index.ts" + ] + ], + "options": { + "composite": true, + "module": 199, + "strict": true + }, + "referencedMap": { + "./in-js.d.ts": [ + "../common.d.ts" + ], + "./index.ts": [ + "../common.d.ts", + "./in-js.d.ts" + ] + }, + "latestChangedDtsFile": "./index.d.ts", + "version": "FakeTSVersion", + "size": 1435 +} + +//// [/home/src/workspaces/project/consumer/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// n is implicitly any because onValue is actually any (despite what the tooltip says) +v.onValue = (n) => { +}; +v2.onValue = (n) => { +}; + + +//// [/home/src/workspaces/project/consumer/tsconfig.tsbuildinfo] +{"root":["./index.ts"],"version":"FakeTSVersion"} + +//// [/home/src/workspaces/project/consumer/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "root": [ + "./index.ts" + ], + "version": "FakeTSVersion", + "size": 49 +} + + +exitCode:: ExitStatus.Success diff --git a/tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts b/tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts new file mode 100644 index 0000000000000..f6fcfdda17091 --- /dev/null +++ b/tests/cases/compiler/privateFieldsInClassExpressionDeclaration.ts @@ -0,0 +1,15 @@ +// @target: ES2015 +// @declaration: true + +export const ClassExpression = class { + #context = 0; + #method() { return 42; } + public value = 1; +}; + +// Additional test with static private fields +export const ClassExpressionStatic = class { + static #staticPrivate = "hidden"; + #instancePrivate = true; + public exposed = "visible"; +}; \ No newline at end of file diff --git a/tests/cases/compiler/typedArrayConstructorOverloads.ts b/tests/cases/compiler/typedArrayConstructorOverloads.ts index c532545d39d1a..63fbfb07a9df0 100644 --- a/tests/cases/compiler/typedArrayConstructorOverloads.ts +++ b/tests/cases/compiler/typedArrayConstructorOverloads.ts @@ -12,6 +12,7 @@ type TypedArrayConstructor = | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor + | Float16ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor diff --git a/tests/cases/fourslash/syntacticClassificationsJsx1.ts b/tests/cases/fourslash/syntacticClassificationsJsx1.ts index 40909ef7bddfd..8e6bfc6462ec1 100644 --- a/tests/cases/fourslash/syntacticClassificationsJsx1.ts +++ b/tests/cases/fourslash/syntacticClassificationsJsx1.ts @@ -18,7 +18,7 @@ verify.syntacticClassificationsAre( c.jsxText(` some jsx text `), - c.punctuation(""), c.punctuation(";"), + c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"), c.keyword("let"), c.identifier("y"), c.operator("="), c.punctuation("<"), c.jsxSelfClosingTagName("element"), @@ -26,8 +26,8 @@ verify.syntacticClassificationsAre( c.punctuation("/"), c.punctuation(">") ) -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable.declaration", "x"), - c2.semanticToken("variable.declaration", "y"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("variable.declaration", "x"), + c2.semanticToken("variable.declaration", "y"), ); diff --git a/tests/cases/fourslash/syntacticClassificationsJsx2.ts b/tests/cases/fourslash/syntacticClassificationsJsx2.ts index d4aff5d1ed85a..6c244ef4b6598 100644 --- a/tests/cases/fourslash/syntacticClassificationsJsx2.ts +++ b/tests/cases/fourslash/syntacticClassificationsJsx2.ts @@ -18,7 +18,7 @@ verify.syntacticClassificationsAre( c.jsxText(` some jsx text `), - c.punctuation(""), c.punctuation(";"), + c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"), c.keyword("let"), c.identifier("y"), c.operator("="), c.punctuation("<"), c.jsxSelfClosingTagName("element.name"), @@ -26,8 +26,8 @@ verify.syntacticClassificationsAre( c.punctuation("/"), c.punctuation(">") ) -const c2 = classification("2020"); -verify.semanticClassificationsAre("2020", - c2.semanticToken("variable.declaration", "x"), - c2.semanticToken("variable.declaration", "y"), +const c2 = classification("2020"); +verify.semanticClassificationsAre("2020", + c2.semanticToken("variable.declaration", "x"), + c2.semanticToken("variable.declaration", "y"), );