Commit 2d8027c 1 parent 35e1a3b commit 2d8027c Copy full SHA for 2d8027c
File tree 6 files changed +8
-26
lines changed
6 files changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -14,5 +14,7 @@ Version 1.0 of `@sveltejs/acorn-typescript` has some breaking changes compared t
14
14
15
15
- Only named export (i.e. you have to do ` import { tsPlugin } from '@sveltejs/acorn-typescript'; ` , a default export is no longer provided)
16
16
- ESM only (no CJS build)
17
+ - JSX parsing is disabled by default now (you can turn it back on by passing ` { jsx: true } ` )
18
+ - ` allowSatisfies ` option was removed, ` satisfies ` operator is always parsed now
17
19
18
20
Changelog of the project this originated from: https://github.com/TyrealHu/acorn-typescript/CHANGELOG.md
Original file line number Diff line number Diff line change 1
1
import { describe , it } from 'vitest' ;
2
- import { equalNode , parseSourceAllowSatisfies , parseSourceShouldThrowError } from '../utils' ;
2
+ import { equalNode , parseSource } from '../utils' ;
3
3
import SatisfiesSnapshot from '../__snapshot__/satisfies' ;
4
4
5
5
describe ( 'satisfies' , function ( ) {
6
6
it ( 'normal' , function ( ) {
7
- const node = parseSourceAllowSatisfies ( 'const a = 1 satisfies any' ) ;
7
+ const node = parseSource ( 'const a = 1 satisfies any' ) ;
8
8
9
9
equalNode ( node , SatisfiesSnapshot . Normal ) ;
10
10
} ) ;
11
-
12
- it ( 'should error' , function ( ) {
13
- parseSourceShouldThrowError ( 'const a = 1 satisfies any' , 'Unexpected token (1:12)' ) ;
14
- } ) ;
15
11
} ) ;
Original file line number Diff line number Diff line change @@ -16,12 +16,6 @@ export const JsxParser = acorn.Parser.extend(
16
16
} )
17
17
) ;
18
18
19
- export const AllowSatisfiesParser = acorn . Parser . extend (
20
- tsPlugin ( {
21
- allowSatisfies : true
22
- } )
23
- ) ;
24
-
25
19
export function equalNode ( node , snapshot ) {
26
20
assert . deepEqual ( JSON . parse ( JSON . stringify ( node ) ) , snapshot , 'should be' + JSON . stringify ( node ) ) ;
27
21
}
@@ -50,14 +44,6 @@ export function parseSource(input: string) {
50
44
} ) ;
51
45
}
52
46
53
- export function parseSourceAllowSatisfies ( input : string ) {
54
- return AllowSatisfiesParser . parse ( input , {
55
- sourceType : 'module' ,
56
- ecmaVersion : 'latest' ,
57
- locations : true
58
- } ) ;
59
- }
60
-
61
47
export function parseSourceShouldThrowError ( input : string , message ?: string ) {
62
48
try {
63
49
Parser . parse ( input , {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { Parser } from 'acorn';
2
2
3
3
export function tsPlugin ( options ?: {
4
4
dts ?: boolean ;
5
- allowSatisfies ?: boolean ;
6
5
/** Whether to use JSX. Defaults to false */
7
6
jsx ?:
8
7
| boolean
Original file line number Diff line number Diff line change @@ -150,9 +150,8 @@ export function tsPlugin(options?: {
150
150
allowNamespaces ?: boolean ;
151
151
allowNamespacedObjects ?: boolean ;
152
152
} ;
153
- allowSatisfies ?: boolean ;
154
153
} ) {
155
- const { dts = false , allowSatisfies = false } = options || { } ;
154
+ const { dts = false } = options || { } ;
156
155
const disallowAmbiguousJSXLike = ! ! options ?. jsx ;
157
156
158
157
return function ( Parser : typeof AcornParseClass ) {
@@ -2897,7 +2896,7 @@ export function tsPlugin(options?: {
2897
2896
nodeType = 'TSAsExpression' ;
2898
2897
}
2899
2898
2900
- if ( allowSatisfies && this . isContextual ( 'satisfies' ) ) {
2899
+ if ( this . isContextual ( 'satisfies' ) ) {
2901
2900
nodeType = 'TSSatisfiesExpression' ;
2902
2901
}
2903
2902
Original file line number Diff line number Diff line change 14
14
"sourceMap" : true ,
15
15
"strict" : false
16
16
} ,
17
- "include" : [ "./src/*" , "./__test__/*" ] ,
18
- "exclude" : [ "./__test__/__snapshots__/*" ]
17
+ "include" : [ "./src/**/* " , "./__test__/** /*" ] ,
18
+ "exclude" : [ "./__test__/__snapshots__/**/* " ]
19
19
}
You can’t perform that action at this time.
0 commit comments