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(ts-estree): convert decorators on var and fn decs#211

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
JamesHenry merged 3 commits intomasterfromdodgy-decorators
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
92 changes: 92 additions & 0 deletionspackages/parser/tests/lib/__snapshots__/typescript.ts.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91249,6 +91249,43 @@ Object {
],
"type": "BlockStatement",
},
"decorators": Array [
Object {
"expression": Object {
"loc": Object {
"end": Object {
"column": 4,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"name": "dec",
"range": Array [
1,
4,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 4,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
4,
],
"type": "Decorator",
},
],
"expression": false,
"generator": false,
"id": Object {
Expand DownExpand Up@@ -91791,6 +91828,61 @@ Object {
"type": "VariableDeclarator",
},
],
"decorators": Array [
Object {
"expression": Object {
"arguments": Array [],
"callee": Object {
"loc": Object {
"end": Object {
"column": 5,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"name": "deco",
"range": Array [
1,
5,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 7,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"range": Array [
1,
7,
],
"type": "CallExpression",
},
"loc": Object {
"end": Object {
"column": 7,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
7,
],
"type": "Decorator",
},
],
"kind": "const",
"loc": Object {
"end": Object {
Expand Down
22 changes: 22 additions & 0 deletionspackages/typescript-estree/src/convert.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -696,6 +696,17 @@ export class Converter {
);
}

/**
* Semantically, decorators are not allowed on function declarations,
* but the TypeScript compiler will parse them and produce a valid AST,
* so we handle them here too.
*/
if (node.decorators) {
(result as any).decorators = node.decorators.map(el =>
this.convertChild(el)
);
}

// check for exports
return fixExports(node, result, this.ast);
}
Expand DownExpand Up@@ -730,6 +741,17 @@ export class Converter {
kind: getDeclarationKind(node.declarationList)
});

/**
* Semantically, decorators are not allowed on variable declarations,
* but the TypeScript compiler will parse them and produce a valid AST,
* so we handle them here too.
*/
if (node.decorators) {
(result as any).decorators = node.decorators.map(el =>
this.convertChild(el)
);
}

if (hasModifier(SyntaxKind.DeclareKeyword, node)) {
result.declare = true;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90557,6 +90557,43 @@ Object {
],
"type": "BlockStatement",
},
"decorators": Array [
Object {
"expression": Object {
"loc": Object {
"end": Object {
"column": 4,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"name": "dec",
"range": Array [
1,
4,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 4,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
4,
],
"type": "Decorator",
},
],
"expression": false,
"generator": false,
"id": Object {
Expand DownExpand Up@@ -91097,6 +91134,61 @@ Object {
"type": "VariableDeclarator",
},
],
"decorators": Array [
Object {
"expression": Object {
"arguments": Array [],
"callee": Object {
"loc": Object {
"end": Object {
"column": 5,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"name": "deco",
"range": Array [
1,
5,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 7,
"line": 1,
},
"start": Object {
"column": 1,
"line": 1,
},
},
"range": Array [
1,
7,
],
"type": "CallExpression",
},
"loc": Object {
"end": Object {
"column": 7,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
7,
],
"type": "Decorator",
},
],
"kind": "const",
"loc": Object {
"end": Object {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp