Skip to content

Test stuff #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
97c75da
Added test error to completion
Mar 6, 2023
1c1022b
Changed a bit
Mar 7, 2023
4e672e7
More errors
Mar 10, 2023
92ab2e2
Fix
Mar 10, 2023
287ee41
Fix two module specifier ending preference detection issues (#53691)
andrewbranch Apr 6, 2023
7f63767
Reuse operandType in checkPrefixUnaryExpression (#53682)
jakebailey Apr 6, 2023
85f2024
Make the server logs more stable by stubbing time and seq info in the…
sheetalkamat Apr 6, 2023
d23b7e7
export TypingsInstaller from tsserverlibrary (#53394)
zkat Apr 7, 2023
c89f87f
Detect malformed UTF-8 files and refuse to engage further (#53667)
RyanCavanaugh Apr 7, 2023
d4c48e1
Adds linked editing for JSX tags (#53284)
iisaduan Apr 7, 2023
c61abc9
Update package-lock.json
typescript-bot Apr 8, 2023
0f724c0
Update package-lock.json
typescript-bot Apr 10, 2023
8369d41
fix ordering of code fix import with triple-slash directives (#52484)
Tobias-Scholz Apr 10, 2023
a97ba98
infer from usages: support short-circuiting assignment operators (#52…
zardoy Apr 10, 2023
926c6f1
Some of the test updates to ensure that it still tests what it is sup…
sheetalkamat Apr 10, 2023
3e76fb5
Fix CJS local binding emit for ES decorators (#53725)
rbuckton Apr 10, 2023
4615e52
Update more tests for paths (#53728)
sheetalkamat Apr 10, 2023
7b2b6a8
fix(19577): fix regression with fully inferred types and non-null ass…
nicolas377 Apr 11, 2023
89a6482
Update package-lock.json
typescript-bot Apr 11, 2023
af5e8e2
fix(lib.d.ts): fixed buffer parameter type of `DataView` (#53130)
lpizzinidev Apr 11, 2023
23469e9
Declare `reportError` as returning `never` in fourslash (#53741)
DanielRosenwasser Apr 11, 2023
2db688e
Reset type resolution stack when starting to compute variance (#53549)
gabritto Apr 11, 2023
bec204c
Revise `discriminateTypeByDiscriminableItems` function (#53709)
ahejlsberg Apr 12, 2023
a26175b
Ensure findPrecedingToken recurses into JSDoc children when needed (#…
jakebailey Apr 12, 2023
fd6f61e
add Intl.supportedValuesOf (#53511)
KhafraDev Apr 12, 2023
0023505
Removed unnecessary use-before-define error for const enums (#53625)
JoshuaKGoldberg Apr 12, 2023
33ab6fd
lib Fix Part 5/6 – Function.{apply, bind} (#50453)
graphemecluster Apr 12, 2023
adcc39d
Allow custom switch-case indentation in formatting (#53733)
donaldnevermore Apr 13, 2023
537cd60
Truncate long files in fourslash baselines around +- n lines (#53769)
sheetalkamat Apr 13, 2023
1af17f8
Fix transform flags for certain ES2020 features. (#52445)
DanielRosenwasser Apr 13, 2023
df3bec6
Tweak module resolution failed lookup watching (#53591)
sheetalkamat Apr 13, 2023
458c5e6
fix(53138): go-to-definition not working on expression of SatisfiesEx…
Zzzen Apr 13, 2023
3445e58
Update package-lock.json
typescript-bot Apr 14, 2023
b798e6b
Optimize union type creation (#53771)
ahejlsberg Apr 14, 2023
b92483f
RFC: Consult new JSX.ElementType for valid JSX element types (#51328)
eps1lon Apr 14, 2023
e49db97
Exclude parameters of non-inferrable signatures from inference (#53756)
ahejlsberg Apr 14, 2023
f306e4e
Force add lib in workflows which commit LKG (#53248)
jakebailey Apr 14, 2023
0c5be02
feat(7411): JSX namespaced attribute syntax not supported (#47356)
a-tarasyuk Apr 14, 2023
c70fa51
Don't include completions for current and later parameters (#52690)
zardoy Apr 15, 2023
04f813d
Bump minimum Node to 14.17, ES to 2020 for TS 5.1 (#53291)
jakebailey Apr 15, 2023
bdcf8ab
Update package-lock.json
typescript-bot Apr 15, 2023
5897d7a
Report assignability errors on the `satisfies` keyword (#53797)
Andarist Apr 16, 2023
f8b3ea7
Propagate `errorType` in `getConditionalType` (#53801)
ahejlsberg Apr 16, 2023
378ffa4
feat(7411): Resolve intrinsics elements by JSX namespaced tag names (…
a-tarasyuk Apr 17, 2023
e782cef
Properly handle partial union type properties in `isTypePresencePossi…
ahejlsberg Apr 17, 2023
430c5be
Update package-lock.json
typescript-bot Apr 17, 2023
020ce0c
feat(7411): Add additional test cases (#53809)
a-tarasyuk Apr 17, 2023
53d3787
When installing unrelated package inside scoped packages dont invalid…
sheetalkamat Apr 17, 2023
9919f6d
Dont defer non relative type reference directive resolutions watching…
sheetalkamat Apr 17, 2023
b269087
Fixed an issue with JSX children expression not being contextually di…
Andarist Apr 17, 2023
6f9a062
feat(7411) - Replace helper to get namespaced name (#53876)
a-tarasyuk Apr 17, 2023
1a003b9
Merge remote-tracking branch 'upstream/main' into TestBranch
Apr 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/new-release-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
git add src/compiler/corePublic.ts
git add tests/baselines/reference/api/typescript.d.ts
git add tests/baselines/reference/api/tsserverlibrary.d.ts
git add ./lib
git add --force ./lib
git config user.email "typescriptbot@microsoft.com"
git config user.name "TypeScript Bot"
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/set-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
git add src/compiler/corePublic.ts
git add tests/baselines/reference/api/typescript.d.ts
git add tests/baselines/reference/api/tsserverlibrary.d.ts
git add ./lib
git add --force ./lib
git config user.email "typescriptbot@microsoft.com"
git config user.name "TypeScript Bot"
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-lkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
npx hereby LKG
npm test
git diff
git add ./lib
git add --force ./lib
git commit -m "Update LKG"
git push
2 changes: 1 addition & 1 deletion Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
bundle: true,
outfile,
platform: "node",
target: "es2018",
target: ["es2020", "node14.17"],
format: "cjs",
sourcemap: "linked",
sourcesContent: false,
Expand Down
649 changes: 326 additions & 323 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"tsserver": "./bin/tsserver"
},
"engines": {
"node": ">=12.20"
"node": ">=14.17"
},
"files": [
"bin",
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import {
getEnclosingBlockScopeContainer,
getErrorSpanForNode,
getEscapedTextOfIdentifierOrLiteral,
getEscapedTextOfJsxNamespacedName,
getExpandoInitializer,
getHostSignatureFromJSDoc,
getImmediatelyInvokedFunctionExpression,
Expand Down Expand Up @@ -171,6 +172,7 @@ import {
isJSDocTemplateTag,
isJSDocTypeAlias,
isJsonSourceFile,
isJsxNamespacedName,
isLeftHandSideExpression,
isLogicalOrCoalescingAssignmentExpression,
isLogicalOrCoalescingAssignmentOperator,
Expand Down Expand Up @@ -679,6 +681,9 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
const containingClassSymbol = containingClass.symbol;
return getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
}
if (isJsxNamespacedName(name)) {
return getEscapedTextOfJsxNamespacedName(name);
}
return isPropertyNameLiteral(name) ? getEscapedTextOfIdentifierOrLiteral(name) : undefined;
}
switch (node.kind) {
Expand Down
262 changes: 159 additions & 103 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,10 @@
"category": "Error",
"code": 1489
},
"File appears to be binary.": {
"category": "Error",
"code": 1490
},

"The types of '{0}' are incompatible between these types.": {
"category": "Error",
Expand Down Expand Up @@ -2889,6 +2893,10 @@
"category": "Error",
"code": 2638
},
"React components cannot include JSX namespace names": {
"category": "Error",
"code": 2639
},

"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
"category": "Error",
Expand Down Expand Up @@ -7756,5 +7764,9 @@
"Non-abstract class '{0}' does not implement all abstract members of '{1}'": {
"category": "Error",
"code": 18052
},
"Its type '{0}' is not a valid JSX element type.": {
"category": "Error",
"code": 18053
}
}
9 changes: 9 additions & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ import {
JsxEmit,
JsxExpression,
JsxFragment,
JsxNamespacedName,
JsxOpeningElement,
JsxOpeningFragment,
JsxSelfClosingElement,
Expand Down Expand Up @@ -2283,6 +2284,8 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
return emitJsxSelfClosingElement(node as JsxSelfClosingElement);
case SyntaxKind.JsxFragment:
return emitJsxFragment(node as JsxFragment);
case SyntaxKind.JsxNamespacedName:
return emitJsxNamespacedName(node as JsxNamespacedName);

// Synthesized list
case SyntaxKind.SyntaxList:
Expand Down Expand Up @@ -4225,6 +4228,12 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
}
}

function emitJsxNamespacedName(node: JsxNamespacedName) {
emitIdentifierName(node.namespace);
writePunctuation(":");
emitIdentifierName(node.name);
}

function emitJsxTagName(node: JsxTagNameExpression) {
if (node.kind === SyntaxKind.Identifier) {
emitExpression(node);
Expand Down
34 changes: 29 additions & 5 deletions src/compiler/factory/nodeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ import {
JSDocVariadicType,
JsxAttribute,
JsxAttributeLike,
JsxAttributeName,
JsxAttributes,
JsxAttributeValue,
JsxChild,
Expand All @@ -275,6 +276,7 @@ import {
JsxElement,
JsxExpression,
JsxFragment,
JsxNamespacedName,
JsxOpeningElement,
JsxOpeningFragment,
JsxSelfClosingElement,
Expand Down Expand Up @@ -908,6 +910,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
updateJsxSpreadAttribute,
createJsxExpression,
updateJsxExpression,
createJsxNamespacedName,
updateJsxNamespacedName,
createCaseClause,
updateCaseClause,
createDefaultClause,
Expand Down Expand Up @@ -1105,7 +1109,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
function createBigIntLiteral(value: string | PseudoBigInt): BigIntLiteral {
const node = createBaseToken<BigIntLiteral>(SyntaxKind.BigIntLiteral);
node.text = typeof value === "string" ? value : pseudoBigIntToString(value) + "n";
node.transformFlags |= TransformFlags.ContainsESNext;
node.transformFlags |= TransformFlags.ContainsES2020;
return node;
}

Expand Down Expand Up @@ -3675,7 +3679,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
node.transformFlags |= TransformFlags.ContainsES2015;
break;
case SyntaxKind.ImportKeyword:
node.transformFlags |= TransformFlags.ContainsESNext;
node.transformFlags |= TransformFlags.ContainsES2020;
break;
default:
return Debug.assertNever(keywordToken);
Expand Down Expand Up @@ -4715,7 +4719,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
node.name = name;
node.transformFlags |=
propagateChildFlags(node.name) |
TransformFlags.ContainsESNext;
TransformFlags.ContainsES2020;
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
return node;
}
Expand Down Expand Up @@ -5582,7 +5586,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
}

// @api
function createJsxAttribute(name: Identifier, initializer: JsxAttributeValue | undefined) {
function createJsxAttribute(name: JsxAttributeName, initializer: JsxAttributeValue | undefined) {
const node = createBaseDeclaration<JsxAttribute>(SyntaxKind.JsxAttribute);
node.name = name;
node.initializer = initializer;
Expand All @@ -5594,7 +5598,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
}

// @api
function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: JsxAttributeValue | undefined) {
function updateJsxAttribute(node: JsxAttribute, name: JsxAttributeName, initializer: JsxAttributeValue | undefined) {
return node.name !== name
|| node.initializer !== initializer
? update(createJsxAttribute(name, initializer), node)
Expand Down Expand Up @@ -5654,6 +5658,26 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
: node;
}

// @api
function createJsxNamespacedName(namespace: Identifier, name: Identifier) {
const node = createBaseNode<JsxNamespacedName>(SyntaxKind.JsxNamespacedName);
node.namespace = namespace;
node.name = name;
node.transformFlags |=
propagateChildFlags(node.namespace) |
propagateChildFlags(node.name) |
TransformFlags.ContainsJsx;
return node;
}

// @api
function updateJsxNamespacedName(node: JsxNamespacedName, namespace: Identifier, name: Identifier) {
return node.namespace !== namespace
|| node.name !== name
? update(createJsxNamespacedName(namespace, name), node)
: node;
}

//
// Clauses
//
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/factory/nodeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import {
JsxElement,
JsxExpression,
JsxFragment,
JsxNamespacedName,
JsxOpeningElement,
JsxOpeningFragment,
JsxSelfClosingElement,
Expand Down Expand Up @@ -963,6 +964,10 @@ export function isJsxExpression(node: Node): node is JsxExpression {
return node.kind === SyntaxKind.JsxExpression;
}

export function isJsxNamespacedName(node: Node): node is JsxNamespacedName {
return node.kind === SyntaxKind.JsxNamespacedName;
}

// Clauses

export function isCaseClause(node: Node): node is CaseClause {
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1889,24 +1889,24 @@ export function pathContainsNodeModules(path: string): boolean {
*
* @internal
*/
export function parseNodeModuleFromPath(resolved: string): string | undefined {
export function parseNodeModuleFromPath(resolved: string, isFolder?: boolean): string | undefined {
const path = normalizePath(resolved);
const idx = path.lastIndexOf(nodeModulesPathPart);
if (idx === -1) {
return undefined;
}

const indexAfterNodeModules = idx + nodeModulesPathPart.length;
let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules, isFolder);
if (path.charCodeAt(indexAfterNodeModules) === CharacterCodes.at) {
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName, isFolder);
}
return path.slice(0, indexAfterPackageName);
}

function moveToNextDirectorySeparatorIfAvailable(path: string, prevSeparatorIndex: number): number {
function moveToNextDirectorySeparatorIfAvailable(path: string, prevSeparatorIndex: number, isFolder: boolean | undefined): number {
const nextSeparatorIndex = path.indexOf(directorySeparator, prevSeparatorIndex + 1);
return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
return nextSeparatorIndex === -1 ? isFolder ? path.length : prevSeparatorIndex : nextSeparatorIndex;
}

function loadModuleFromFileNoPackageId(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined {
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ function getPreferences(
return [ModuleSpecifierEnding.JsExtension];
}
if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic) {
return [ModuleSpecifierEnding.Index, ModuleSpecifierEnding.JsExtension];
return preferredEnding === ModuleSpecifierEnding.JsExtension
? [ModuleSpecifierEnding.JsExtension, ModuleSpecifierEnding.Index]
: [ModuleSpecifierEnding.Index, ModuleSpecifierEnding.JsExtension];
}
switch (preferredEnding) {
case ModuleSpecifierEnding.JsExtension: return [ModuleSpecifierEnding.JsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index];
Expand Down
42 changes: 37 additions & 5 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ import {
JsxElement,
JsxExpression,
JsxFragment,
JsxNamespacedName,
JsxOpeningElement,
JsxOpeningFragment,
JsxOpeningLikeElement,
Expand Down Expand Up @@ -1030,6 +1031,10 @@ const forEachChildTable: ForEachChildTable = {
[SyntaxKind.JsxClosingElement]: function forEachChildInJsxClosingElement<T>(node: JsxClosingElement, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.tagName);
},
[SyntaxKind.JsxNamespacedName]: function forEachChildInJsxNamespacedName<T>(node: JsxNamespacedName, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.namespace) ||
visitNode(cbNode, node.name);
},
[SyntaxKind.OptionalType]: forEachChildInOptionalRestOrJSDocParameterModifier,
[SyntaxKind.RestType]: forEachChildInOptionalRestOrJSDocParameterModifier,
[SyntaxKind.JSDocTypeExpression]: forEachChildInOptionalRestOrJSDocParameterModifier,
Expand Down Expand Up @@ -6102,20 +6107,31 @@ namespace Parser {

function parseJsxElementName(): JsxTagNameExpression {
const pos = getNodePos();
scanJsxIdentifier();
// JsxElement can have name in the form of
// propertyAccessExpression
// primaryExpression in the form of an identifier and "this" keyword
// We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
// We only want to consider "this" as a primaryExpression
let expression: JsxTagNameExpression = token() === SyntaxKind.ThisKeyword ?
parseTokenNode<ThisExpression>() : parseIdentifierName();
let expression: JsxTagNameExpression = parseJsxTagName();
while (parseOptional(SyntaxKind.DotToken)) {
expression = finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos) as JsxTagNamePropertyAccess;
}
return expression;
}

function parseJsxTagName(): Identifier | JsxNamespacedName | ThisExpression {
const pos = getNodePos();
scanJsxIdentifier();

const isThis = token() === SyntaxKind.ThisKeyword;
const tagName = parseIdentifierName();
if (parseOptional(SyntaxKind.ColonToken)) {
scanJsxIdentifier();
return finishNode(factory.createJsxNamespacedName(tagName, parseIdentifierName()), pos);
}
return isThis ? finishNode(factory.createToken(SyntaxKind.ThisKeyword), pos) : tagName;
}

function parseJsxExpression(inExpressionContext: boolean): JsxExpression | undefined {
const pos = getNodePos();
if (!parseExpected(SyntaxKind.OpenBraceToken)) {
Expand Down Expand Up @@ -6148,9 +6164,8 @@ namespace Parser {
return parseJsxSpreadAttribute();
}

scanJsxIdentifier();
const pos = getNodePos();
return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos);
return finishNode(factory.createJsxAttribute(parseJsxAttributeName(), parseJsxAttributeValue()), pos);
}

function parseJsxAttributeValue(): JsxAttributeValue | undefined {
Expand All @@ -6169,6 +6184,18 @@ namespace Parser {
return undefined;
}

function parseJsxAttributeName() {
const pos = getNodePos();
scanJsxIdentifier();

const attrName = parseIdentifierName();
if (parseOptional(SyntaxKind.ColonToken)) {
scanJsxIdentifier();
return finishNode(factory.createJsxNamespacedName(attrName, parseIdentifierName()), pos);
}
return attrName;
}

function parseJsxSpreadAttribute(): JsxSpreadAttribute {
const pos = getNodePos();
parseExpected(SyntaxKind.OpenBraceToken);
Expand Down Expand Up @@ -10425,6 +10452,11 @@ export function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagName
return true;
}

if (lhs.kind === SyntaxKind.JsxNamespacedName) {
return lhs.namespace.escapedText === (rhs as JsxNamespacedName).namespace.escapedText &&
lhs.name.escapedText === (rhs as JsxNamespacedName).name.escapedText;
}

// If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only
// take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression
// it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element
Expand Down
Loading