Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(typescript-estree): wrap import = declaration in an export node#5885

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
7a25528
fix(typescript-estree): wrap import = declaration in an export node
JoshuaKGoldbergOct 25, 2022
0414e4d
fix(utils): removed `TRuleListener` generic from the `createRule` (#5…
AndaristOct 25, 2022
04488c2
feat: create TSTypeQuery node when TSImportType has isTypeOf (#3076)
armano2Oct 26, 2022
ee2fbfa
Merge branch 'main' into v6
JoshuaKGoldbergOct 26, 2022
c446386
feat(scope-manager): ignore ECMA version (#5889)
JoshuaKGoldbergOct 26, 2022
cf2956f
feat: remove semantically invalid properties from TSEnumDeclaration, …
juank1809Oct 26, 2022
b90e7c3
fix(eslint-plugin): remove valid-typeof disable in eslint-recommended…
JoshuaKGoldbergOct 26, 2022
fff0e29
feat(utils): remove (ts-)eslint-scope types (#5256)
JoshuaKGoldbergOct 26, 2022
a027cec
Updated snapshots again
JoshuaKGoldbergOct 26, 2022
3d85274
Merge branch 'main' into v6
JoshuaKGoldbergOct 26, 2022
51d97ae
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergOct 26, 2022
16a5cfb
Merge branch 'main' into import-equals-wrap-node
JoshuaKGoldbergNov 18, 2022
74839f9
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergNov 28, 2022
8dd2a42
Remove silly comment
JoshuaKGoldbergNov 28, 2022
58c4d34
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergDec 11, 2022
b36507f
Just a bit of cleanup
JoshuaKGoldbergDec 11, 2022
dd858f6
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergDec 16, 2022
28863a4
Remove from ignoreSourceType
JoshuaKGoldbergDec 16, 2022
b331c98
Remove more fixtures-to-test changes
JoshuaKGoldbergDec 16, 2022
a128343
Revert "Remove more fixtures-to-test changes"
JoshuaKGoldbergDec 16, 2022
c60da02
Explained ignoring in comment
JoshuaKGoldbergDec 16, 2022
d2d052d
remove the wat
JoshuaKGoldbergDec 16, 2022
c7ea8eb
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergDec 16, 2022
a738b91
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergDec 16, 2022
79a5f81
Merge branch 'v6' into import-equals-wrap-node
JoshuaKGoldbergFeb 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
moduleReference: TSQualifiedName {
type: "TSQualifiedName",
left: TSQualifiedName {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,5 +2,88 @@

exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many AST Alignment - AST 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
- TSESTree
+ Babel

Program {
type: 'Program',
body: Array [
TSImportEqualsDeclaration {
type: 'TSImportEqualsDeclaration',
id: Identifier {
type: 'Identifier',
name: 'F',

range: [7, 8],
loc: {
start: { column: 7, line: 1 },
end: { column: 8, line: 1 },
},
},
importKind: 'value',
+ isExport: false,
moduleReference: TSQualifiedName {
type: 'TSQualifiedName',
left: TSQualifiedName {
type: 'TSQualifiedName',
left: Identifier {
type: 'Identifier',
name: 'A',

range: [11, 12],
loc: {
start: { column: 11, line: 1 },
end: { column: 12, line: 1 },
},
},
right: Identifier {
type: 'Identifier',
name: 'B',

range: [13, 14],
loc: {
start: { column: 13, line: 1 },
end: { column: 14, line: 1 },
},
},

range: [11, 14],
loc: {
start: { column: 11, line: 1 },
end: { column: 14, line: 1 },
},
},
right: Identifier {
type: 'Identifier',
name: 'C',

range: [15, 16],
loc: {
start: { column: 15, line: 1 },
end: { column: 16, line: 1 },
},
},

range: [11, 16],
loc: {
start: { column: 11, line: 1 },
end: { column: 16, line: 1 },
},
},

range: [0, 17],
loc: {
start: { column: 0, line: 1 },
end: { column: 17, line: 1 },
},
},
],
sourceType: 'script',

range: [0, 18],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}"
`;
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
moduleReference: Identifier {
type: "Identifier",
name: "A",
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,5 +2,50 @@

exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one AST Alignment - AST 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
- TSESTree
+ Babel

Program {
type: 'Program',
body: Array [
TSImportEqualsDeclaration {
type: 'TSImportEqualsDeclaration',
id: Identifier {
type: 'Identifier',
name: 'F',

range: [7, 8],
loc: {
start: { column: 7, line: 1 },
end: { column: 8, line: 1 },
},
},
importKind: 'value',
+ isExport: false,
moduleReference: Identifier {
type: 'Identifier',
name: 'A',

range: [11, 12],
loc: {
start: { column: 11, line: 1 },
end: { column: 12, line: 1 },
},
},

range: [0, 13],
loc: {
start: { column: 0, line: 1 },
end: { column: 13, line: 1 },
},
},
],
sourceType: 'script',

range: [0, 14],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 2 },
},
}"
`;
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,6 @@ Program {
},
},
importKind: "value",
isExport: false,
moduleReference: TSExternalModuleReference {
type: "TSExternalModuleReference",
expression: Literal {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-
},
},
importKind: 'value',
isExport: false,
+ isExport: false,
moduleReference: TSExternalModuleReference {
type: 'TSExternalModuleReference',
expression: Literal {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,12 +22,4 @@ export interface TSImportEqualsDeclaration extends BaseNode {
moduleReference: EntityName | TSExternalModuleReference;
// TODO(#1852) - breaking change remove this as it is invalid
importKind: ImportKind;
/**
* Whether this is immediately exported
* ```
* export import F = A;
* ```
*/
// TODO(#4130) - this should be represented in the AST
isExport: boolean;
}
2 changes: 2 additions & 0 deletionspackages/ast-spec/src/unions/ExportDeclaration.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import type {
} from '../declaration/FunctionDeclaration/spec';
import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec';
import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec';
import type { TSImportEqualsDeclaration } from '../declaration/TSImportEqualsDeclaration/spec';
import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec';
import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec';
import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec';
Expand DownExpand Up@@ -37,6 +38,7 @@ export type NamedExportDeclarations =
| FunctionDeclarationWithOptionalName
| TSDeclareFunction
| TSEnumDeclaration
| TSImportEqualsDeclaration
| TSInterfaceDeclaration
| TSModuleDeclaration
| TSTypeAliasDeclaration
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,8 @@ Set {
"declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts",
"declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts",
"declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts",
Expand Down
34 changes: 20 additions & 14 deletionspackages/typescript-estree/src/convert.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -143,6 +143,7 @@ export class Converter {
| ts.ClassDeclaration
| ts.ClassExpression
| ts.TypeAliasDeclaration
| ts.ImportEqualsDeclaration
| ts.InterfaceDeclaration
| ts.EnumDeclaration
| ts.ModuleDeclaration,
Expand All@@ -159,7 +160,7 @@ export class Converter {
const exportKeyword = modifiers[0];
const nextModifier = modifiers[1];
const declarationIsDefault =
nextModifier && nextModifier.kind === SyntaxKind.DefaultKeyword;
nextModifier?.kind === SyntaxKind.DefaultKeyword;

const varToken = declarationIsDefault
? findNextToken(nextModifier, this.ast, this.ast)
Expand All@@ -169,12 +170,15 @@ export class Converter {
result.loc = getLocFor(result.range[0], result.range[1], this.ast);

if (declarationIsDefault) {
return this.createNode<TSESTree.ExportDefaultDeclaration>(node, {
type: AST_NODE_TYPES.ExportDefaultDeclaration,
declaration: result,
range: [exportKeyword.getStart(this.ast), result.range[1]],
exportKind: 'value',
});
return this.createNode<TSESTree.ExportDefaultDeclaration>(
node as Exclude<typeof node, ts.ImportEqualsDeclaration>,
{
type: AST_NODE_TYPES.ExportDefaultDeclaration,
declaration: result as TSESTree.DefaultExportDeclarations,
range: [exportKeyword.getStart(this.ast), result.range[1]],
exportKind: 'value',
},
);
} else {
const isType =
result.type === AST_NODE_TYPES.TSInterfaceDeclaration ||
Expand DownExpand Up@@ -2778,13 +2782,15 @@ export class Converter {
});
}
case SyntaxKind.ImportEqualsDeclaration: {
return this.createNode<TSESTree.TSImportEqualsDeclaration>(node, {
type: AST_NODE_TYPES.TSImportEqualsDeclaration,
id: this.convertChild(node.name),
moduleReference: this.convertChild(node.moduleReference),
importKind: node.isTypeOnly ? 'type' : 'value',
isExport: hasModifier(SyntaxKind.ExportKeyword, node),
});
return this.fixExports(
node,
this.createNode<TSESTree.TSImportEqualsDeclaration>(node, {
type: AST_NODE_TYPES.TSImportEqualsDeclaration,
id: this.convertChild(node.name),
importKind: node.isTypeOnly ? 'type' : 'value',
moduleReference: this.convertChild(node.moduleReference),
}),
);
}
case SyntaxKind.ExternalModuleReference: {
return this.createNode<TSESTree.TSExternalModuleReference>(node, {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ export interface EstreeToTsNodeTypes {
| ts.ClassDeclaration
| ts.ClassExpression
| ts.TypeAliasDeclaration
| ts.ImportEqualsDeclaration
| ts.InterfaceDeclaration
| ts.EnumDeclaration
| ts.ModuleDeclaration;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -371,6 +371,16 @@ tester.addFixturePatternConfig('typescript/basics', {
'class-with-two-methods-computed-constructor',
'export-type-star-from',
'import-type-error',

/**
* Babel's 'typescript' transform gives these TypeScript-like properties
* such as `isExport: false`, but we don't include those in our AST.
*/
'import-equal-declaration',
'import-export-equal-declaration',
'import-equal-type-declaration',
'import-export-equal-type-declaration',

/**
* [TS-ESTREE ERRORED, BUT BABEL DID NOT]
* This is intentional; babel is not checking types
Expand DownExpand Up@@ -404,10 +414,6 @@ tester.addFixturePatternConfig('typescript/basics', {
* @see https://github.com/babel/babel/issues/9213
*/
'export-assignment',
'import-equal-declaration',
'import-export-equal-declaration',
'import-equal-type-declaration',
'import-export-equal-type-declaration',
// babel treats declare and types as not a module
'export-declare-const-named-enum',
'export-declare-named-enum',
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,6 @@ Object {
"type": "Identifier",
},
"importKind": "value",
"isExport": false,
"loc": Object {
"end": Object {
"column": 28,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,6 @@ Object {
"type": "Identifier",
},
"importKind": "type",
"isExport": false,
"loc": Object {
"end": Object {
"column": 33,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp