Skip to content
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

feat: allow typescript@5.3.0-beta as devDependency #7821

Merged
@@ -1,8 +1,8 @@
diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts
index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038a7fe4164 100644
index d785077fd9e4eb5959c0badb857358fad09d4d3f..54f71344b098e8d46acd8dd77638c60d505bb996 100644
--- a/lib/typescript.d.ts
+++ b/lib/typescript.d.ts
@@ -371,8 +371,8 @@ declare namespace ts {
@@ -4491,8 +4491,8 @@ declare namespace ts {
JSDocFunctionType = 324,
JSDocVariadicType = 325,
JSDocNamepathType = 326,
Expand All @@ -12,7 +12,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
JSDocComment = 327,
JSDocText = 328,
JSDocTypeLiteral = 329,
@@ -738,6 +738,8 @@ declare namespace ts {
@@ -5066,6 +5066,8 @@ declare namespace ts {
readonly name: PropertyName;
readonly questionToken?: QuestionToken;
readonly type?: TypeNode;
Expand All @@ -21,7 +21,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
}
interface PropertyDeclaration extends ClassElement, JSDocContainer {
readonly kind: SyntaxKind.PropertyDeclaration;
@@ -763,6 +765,10 @@ declare namespace ts {
@@ -5091,6 +5093,10 @@ declare namespace ts {
readonly parent: ObjectLiteralExpression;
readonly name: PropertyName;
readonly initializer: Expression;
Expand All @@ -32,7 +32,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
}
interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer {
readonly kind: SyntaxKind.ShorthandPropertyAssignment;
@@ -770,6 +776,12 @@ declare namespace ts {
@@ -5098,6 +5104,12 @@ declare namespace ts {
readonly name: Identifier;
readonly equalsToken?: EqualsToken;
readonly objectAssignmentInitializer?: Expression;
Expand All @@ -45,7 +45,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
}
interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer {
readonly kind: SyntaxKind.SpreadAssignment;
@@ -892,6 +904,8 @@ declare namespace ts {
@@ -5222,6 +5234,8 @@ declare namespace ts {
}
interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
readonly kind: SyntaxKind.FunctionType;
Expand All @@ -54,7 +54,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
}
interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase, LocalsContainer {
readonly kind: SyntaxKind.ConstructorType;
@@ -4584,7 +4598,13 @@ declare namespace ts {
@@ -8978,7 +8992,13 @@ declare namespace ts {
function symbolName(symbol: Symbol): string;
function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined;
function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined;
Expand All @@ -68,7 +68,7 @@ index ead6d07d8fb2af6aa74b790c9fd947f1062f6df4..f8dad7f06e74d7cfccfcd8fc9c5c7038
function getModifiers(node: HasModifiers): readonly Modifier[] | undefined;
/**
* Gets the JSDoc parameter tags for the node if present.
@@ -5110,7 +5130,13 @@ declare namespace ts {
@@ -9508,7 +9528,13 @@ declare namespace ts {
function isModuleName(node: Node): node is ModuleName;
function isBinaryOperatorToken(node: Node): node is BinaryOperatorToken;
function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -114,7 +114,7 @@
"ts-node": "10.7.0",
"tslint": "^6.1.3",
"tsx": "^3.12.7",
"typescript": ">=4.3.5 <5.3.0"
"typescript": ">=4.3.5 <5.4.0"
},
"resolutions": {
"@jest/create-cache-key-function": "^29",
Expand All @@ -140,7 +140,7 @@
"pretty-format": "^29",
"react-split-pane@^0.1.92": "patch:react-split-pane@npm%3A0.1.92#./.yarn/patches/react-split-pane-npm-0.1.92-93dbf51dff.patch",
"tsx": "^3.12.7",
"typescript": "patch:typescript@npm%3A5.2.2#./.yarn/patches/typescript-npm-5.2.2-01717e9f84.patch"
"typescript": "patch:typescript@npm%3A5.3.0-beta#./.yarn/patches/typescript-npm-5.3.0-beta-33b1e90865.patch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The future is now old man dot jpg

We can switch this to the 5.3 RC now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarnpkg/berry#4441 keeps hitting me shakes fist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

microsoft/TypeScript#56371 never mind 🥲

},
"packageManager": "yarn@3.6.4"
}
2 changes: 1 addition & 1 deletion packages/ast-spec/package.json
Expand Up @@ -47,7 +47,7 @@
"@babel/core": "*",
"@babel/eslint-parser": "*",
"@babel/parser": "*",
"@microsoft/api-extractor": "^7.36.1",
"@microsoft/api-extractor": "^7.38.0",
"glob": "*",
"jest": "29.7.0",
"jest-diff": "^29.6.2",
Expand Down
Expand Up @@ -12,8 +12,16 @@ export interface ExportAllDeclaration extends BaseNode {
* ```
* export * from 'mod' assert { type: 'json' };
* ```
* @deprecated -- Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* export * from 'mod' assert { type: 'json' };
* ```
*/
attributes: ImportAttribute[];
/**
* The name for the exported items. `null` if no name is assigned.
*/
Expand Down
37 changes: 34 additions & 3 deletions packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts
Expand Up @@ -14,8 +14,17 @@ interface ExportNamedDeclarationBase extends BaseNode {
* export { foo } from 'mod' assert { type: 'json' };
* ```
* This will be an empty array if `source` is `null`
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* export { foo } from 'mod' assert { type: 'json' };
* ```
* This will be an empty array if `source` is `null`
*/
attributes: ImportAttribute[];
/**
* The exported declaration.
* ```
Expand Down Expand Up @@ -44,26 +53,48 @@ interface ExportNamedDeclarationBase extends BaseNode {

export interface ExportNamedDeclarationWithoutSourceWithMultiple
extends ExportNamedDeclarationBase {
// this will always be empty array
/**
* This will always be an empty array.
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* This will always be an empty array.
*/
attributes: ImportAttribute[];
declaration: null;
source: null;
specifiers: ExportSpecifier[];
}

export interface ExportNamedDeclarationWithoutSourceWithSingle
extends ExportNamedDeclarationBase {
// this will always be empty array
/**
* This will always be an empty array.
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* This will always be an empty array.
*/
attributes: ImportAttribute[];
declaration: NamedExportDeclarations;
source: null;
// this will always be empty array
//Tthis will always be an empty array.
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
specifiers: ExportSpecifier[];
}

export interface ExportNamedDeclarationWithSource
extends ExportNamedDeclarationBase {
/**
* This will always be an empty array.
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* This will always be an empty array.
*/
attributes: ImportAttribute[];
declaration: null;
source: StringLiteral;
specifiers: ExportSpecifier[];
Expand Down
8 changes: 8 additions & 0 deletions packages/ast-spec/src/declaration/ImportDeclaration/spec.ts
Expand Up @@ -12,8 +12,16 @@ export interface ImportDeclaration extends BaseNode {
* ```
* import * from 'mod' assert { type: 'json' };
* ```
* @deprecated -- Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* import * from 'mod' with { type: 'json' };
* ```
*/
attributes: ImportAttribute[];
/**
* The kind of the import.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/ast-spec/src/declaration/VariableDeclaration/spec.ts
Expand Up @@ -36,7 +36,7 @@ export interface LetOrConstOrVarDeclaration extends BaseNode {
kind: 'const' | 'let' | 'var';
}

export interface UsingInNomalConextDeclaration extends BaseNode {
export interface UsingInNomalContextDeclaration extends BaseNode {
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
type: AST_NODE_TYPES.VariableDeclaration;
/**
* The variables declared by this declaration.
Expand Down Expand Up @@ -91,6 +91,6 @@ export interface UsingInForOfDeclaration extends BaseNode {

export type UsingDeclaration =
| UsingInForOfDeclaration
| UsingInNomalConextDeclaration;
| UsingInNomalContextDeclaration;

export type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
1 change: 1 addition & 0 deletions packages/scope-manager/src/lib/es5.ts
Expand Up @@ -34,6 +34,7 @@ export const es5 = {
ImportMeta: TYPE,
ImportCallOptions: TYPE,
ImportAssertions: TYPE,
ImportAttributes: TYPE,
Math: TYPE_VALUE,
Date: TYPE_VALUE,
DateConstructor: TYPE,
Expand Down
125 changes: 81 additions & 44 deletions packages/typescript-estree/src/convert.ts
Expand Up @@ -199,16 +199,24 @@ export class Converter {
result.type === AST_NODE_TYPES.TSInterfaceDeclaration ||
result.type === AST_NODE_TYPES.TSTypeAliasDeclaration;
const isDeclare = 'declare' in result && result.declare;
return this.createNode<TSESTree.ExportNamedDeclaration>(node, {
type: AST_NODE_TYPES.ExportNamedDeclaration,
return this.createNode<TSESTree.ExportNamedDeclaration>(
node,
// @ts-expect-error - TODO, narrow the types here
declaration: result,
specifiers: [],
source: null,
exportKind: isType || isDeclare ? 'type' : 'value',
range: [exportKeyword.getStart(this.ast), result.range[1]],
assertions: [],
});
this.#withDeprecatedAliasGetter(
{
type: AST_NODE_TYPES.ExportNamedDeclaration,
declaration: result,
specifiers: [],
source: null,
exportKind: isType || isDeclare ? 'type' : 'value',
range: [exportKeyword.getStart(this.ast), result.range[1]],
attributes: [],
},
'assertions',
'attributes',
true,
),
);
}

return result;
Expand Down Expand Up @@ -688,8 +696,8 @@ export class Converter {
});
}

private convertAssertClasue(
node: ts.AssertClause | undefined,
private convertImportAttributes(
node: ts.ImportAttributes | undefined,
): TSESTree.ImportAttribute[] {
return node === undefined
? []
Expand Down Expand Up @@ -1858,13 +1866,24 @@ export class Converter {
case SyntaxKind.ImportDeclaration: {
this.assertModuleSpecifier(node, false);

const result = this.createNode<TSESTree.ImportDeclaration>(node, {
type: AST_NODE_TYPES.ImportDeclaration,
source: this.convertChild(node.moduleSpecifier),
specifiers: [],
importKind: 'value',
assertions: this.convertAssertClasue(node.assertClause),
});
const result = this.createNode<TSESTree.ImportDeclaration>(
node,
this.#withDeprecatedAliasGetter(
{
type: AST_NODE_TYPES.ImportDeclaration,
source: this.convertChild(node.moduleSpecifier),
specifiers: [],
importKind: 'value',
attributes: this.convertImportAttributes(
// eslint-disable-next-line deprecation/deprecation -- TS <5.3
node.attributes ?? node.assertClause,
),
},
'assertions',
'attributes',
true,
),
);

if (node.importClause) {
if (node.importClause.isTypeOnly) {
Expand Down Expand Up @@ -1925,33 +1944,50 @@ export class Converter {
case SyntaxKind.ExportDeclaration: {
if (node.exportClause?.kind === SyntaxKind.NamedExports) {
this.assertModuleSpecifier(node, true);
return this.createNode<TSESTree.ExportNamedDeclaration>(node, {
type: AST_NODE_TYPES.ExportNamedDeclaration,
source: this.convertChild(node.moduleSpecifier),
specifiers: node.exportClause.elements.map(el =>
this.convertChild(el),
return this.createNode<TSESTree.ExportNamedDeclaration>(
node,
this.#withDeprecatedAliasGetter(
{
type: AST_NODE_TYPES.ExportNamedDeclaration,
source: this.convertChild(node.moduleSpecifier),
specifiers: node.exportClause.elements.map(el =>
this.convertChild(el),
),
exportKind: node.isTypeOnly ? 'type' : 'value',
declaration: null,
attributes: this.convertImportAttributes(
// eslint-disable-next-line deprecation/deprecation -- TS <5.3
node.attributes ?? node.assertClause,
),
},
'assertions',
'attributes',
true,
),
exportKind: node.isTypeOnly ? 'type' : 'value',
declaration: null,
assertions: this.convertAssertClasue(node.assertClause),
});
);
}
this.assertModuleSpecifier(node, false);
return this.createNode<TSESTree.ExportAllDeclaration>(node, {
type: AST_NODE_TYPES.ExportAllDeclaration,
source: this.convertChild(node.moduleSpecifier),
exportKind: node.isTypeOnly ? 'type' : 'value',
exported:
// note - for compat with 3.7.x, where node.exportClause is always undefined and
// SyntaxKind.NamespaceExport does not exist yet (i.e. is undefined), this
// cannot be shortened to an optional chain, or else you end up with
// undefined === undefined, and the true path will hard error at runtime
node.exportClause &&
node.exportClause.kind === SyntaxKind.NamespaceExport
? this.convertChild(node.exportClause.name)
: null,
assertions: this.convertAssertClasue(node.assertClause),
});
return this.createNode<TSESTree.ExportAllDeclaration>(
node,
this.#withDeprecatedAliasGetter(
{
type: AST_NODE_TYPES.ExportAllDeclaration,
source: this.convertChild(node.moduleSpecifier),
exportKind: node.isTypeOnly ? 'type' : 'value',
exported:
node.exportClause?.kind === SyntaxKind.NamespaceExport
? this.convertChild(node.exportClause.name)
: null,
attributes: this.convertImportAttributes(
// eslint-disable-next-line deprecation/deprecation -- TS <5.3
node.attributes ?? node.assertClause,
),
},
'assertions',
'attributes',
true,
),
);
}

case SyntaxKind.ExportSpecifier:
Expand Down Expand Up @@ -3144,7 +3180,7 @@ export class Converter {
});
}

case SyntaxKind.AssertEntry: {
case SyntaxKind.ImportAttribute: {
return this.createNode<TSESTree.ImportAttribute>(node, {
type: AST_NODE_TYPES.ImportAttribute,
key: this.convertChild(node.name),
Expand Down Expand Up @@ -3416,8 +3452,9 @@ export class Converter {
node: Properties,
aliasKey: AliasKey,
valueKey: ValueKey,
suppressWarnings = false,
): Properties & Record<AliasKey, Properties[ValueKey]> {
let warned = false;
let warned = suppressWarnings;

Object.defineProperty(node, aliasKey, {
configurable: true,
Expand Down