-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🚀complete parseMaybeDecoratorArguments and ts class
- v1.4.13
- v1.4.12
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
Showing
4 changed files
with
1,702 additions
and
522 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export class DestructuringErrors { | ||
public shorthandAssign: number | ||
public trailingComma: number | ||
public parenthesizedAssign: number | ||
public parenthesizedBind: number | ||
public doubleProto: number | ||
|
||
constructor() { | ||
this.shorthandAssign = | ||
this.trailingComma = | ||
this.parenthesizedAssign = | ||
this.parenthesizedBind = | ||
this.doubleProto = -1 | ||
} | ||
} | ||
|
||
export function isPrivateNameConflicted(privateNameMap, element) { | ||
const name = element.key.name | ||
const curr = privateNameMap[name] | ||
|
||
let next = "true" | ||
if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) { | ||
next = (element.static ? "s" : "i") + element.kind | ||
} | ||
|
||
// `class { get #a(){}; static set #a(_){} }` is also conflict. | ||
if ( | ||
curr === "iget" && next === "iset" || | ||
curr === "iset" && next === "iget" || | ||
curr === "sget" && next === "sset" || | ||
curr === "sset" && next === "sget" | ||
) { | ||
privateNameMap[name] = "true" | ||
return false | ||
} else if (!curr) { | ||
privateNameMap[name] = next | ||
return false | ||
} else { | ||
return true | ||
} | ||
} | ||
|
||
export function checkKeyName(node, name) { | ||
const {computed, key} = node | ||
return !computed && ( | ||
key.type === "Identifier" && key.name === name || | ||
key.type === "Literal" && key.value === name | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,70 @@ | ||
import { TokenType } from 'acorn' | ||
// @ts-ignore | ||
import { TokenType, keywordTypes } from 'acorn' | ||
|
||
const startsExpr = true | ||
|
||
// Succinct definitions of keyword token types | ||
// @ts-ignore | ||
function kw(name, options: any = {}) { | ||
options.keyword = name | ||
return new TokenType(name, options) | ||
} | ||
|
||
function kwLike(_name, options: any = {}) { | ||
return new TokenType('name', options) | ||
} | ||
|
||
export const tsTokenType = { | ||
as: kw('name', { startsExpr }), | ||
from: kw('name', { startsExpr }), | ||
require: kw('name', { startsExpr }), | ||
abstract: kw('name', { startsExpr }), | ||
declare: kw('name', { startsExpr }), | ||
namespace: kw('name', { startsExpr }), | ||
interface: kw('name', { startsExpr }), | ||
type: kw('name', { startsExpr }), | ||
asserts: kw('name', { startsExpr }), | ||
is: kw("name", { startsExpr }), | ||
let: kw("name", { startsExpr }), | ||
enum: kw("name", { startsExpr }), | ||
global: kw("name", { startsExpr }), | ||
as: kwLike('name', { startsExpr }), | ||
assert: kwLike('assert', { startsExpr }), | ||
async: kwLike('async', { startsExpr }), | ||
await: kwLike('await', { startsExpr }), | ||
from: kwLike('from', { startsExpr }), | ||
get: kwLike('get', { startsExpr }), | ||
let: kwLike('let', { startsExpr }), | ||
meta: kwLike('meta', { startsExpr }), | ||
of: kwLike('of', { startsExpr }), | ||
sent: kwLike('sent', { startsExpr }), | ||
set: kwLike('set', { startsExpr }), | ||
static: kwLike('static', { startsExpr }), | ||
yield: kwLike('yield', { startsExpr }), | ||
|
||
// Flow and TypeScript Keywordlike | ||
asserts: kwLike('asserts', { startsExpr }), | ||
checks: kwLike('checks', { startsExpr }), | ||
exports: kwLike('exports', { startsExpr }), | ||
global: kwLike('global', { startsExpr }), | ||
implements: kwLike('implements', { startsExpr }), | ||
intrinsic: kwLike('intrinsic', { startsExpr }), | ||
infer: kwLike('infer', { startsExpr }), | ||
is: kwLike('is', { startsExpr }), | ||
mixins: kwLike('mixins', { startsExpr }), | ||
proto: kwLike('proto', { startsExpr }), | ||
require: kwLike('require', { startsExpr }), | ||
// start: isTSTypeOperator | ||
keyof: kwLike('keyof', { startsExpr }), | ||
readonly: kwLike('readonly', { startsExpr }), | ||
unique: kwLike('unique', { startsExpr }), | ||
// end: isTSTypeOperator | ||
// start: isTSDeclarationStart | ||
abstract: kwLike('abstract', { startsExpr }), | ||
declare: kwLike('declare', { startsExpr }), | ||
enum: kwLike('enum', { startsExpr }), | ||
module: kwLike('module', { startsExpr }), | ||
namespace: kwLike('namespace', { startsExpr }), | ||
// start: isFlowInterfaceOrTypeOrOpaque | ||
interface: kwLike('interface', { startsExpr }), | ||
type: kwLike('type', { startsExpr }), | ||
// end: isTSDeclarationStart | ||
opaque: kwLike('opaque', { startsExpr }), | ||
// end: isFlowInterfaceOrTypeOrOpaque | ||
} | ||
|
||
export const jsxTokenType = { | ||
// jsx | ||
jsxTagStart: new TokenType('jsxTagStart', { startsExpr }) | ||
} | ||
|
||
export const tsKeywordsRegExp = new RegExp( | ||
'^(?:global|enum|let|is|asserts|declare|abstract|as|type|from|require|namespace|interface)$' | ||
`^(?:${Object.keys(tsTokenType).join('|')})$` | ||
) |