Environment
- Linaria version:
@linaria/[email protected]
- Bundler (+ version): N/A
- Node.js version: 16
- OS: N/A
Description
There are cases when a tag parser (or traversal) is too aggressive and causes unexpected failures. There are two cases that I currently found.
CJS re-export produced by TS
// TS code
export { styled } from '@linaria/react'
⬇️⬇️⬇️
// CJS code
var react_1 = /*#__PURE__*/ require('@linaria/react');
Object.defineProperty(exports, 'styled', {
enumerable: true,
get: function () {
return react_1.styled;
},
});
Results in:
SyntaxError: /home/projects/node-hyqpx9/code/exampleB.js: /home/projects/node-hyqpx9/code/exampleB.js: Invalid usage of `styled` tag
4 | enumerable: true,
5 | get: function () {
> 6 | return react_1.styled;
| ^^^^^^^
7 | },
8 | });
9 |
- Source in
./code/exampleB.js
- To run
node ./testB.js
Usage of identifier in TS types
import { styled } from '@linaria/react';
export type StyledReturn = ReturnType<typeof styled>;
Results in:
SyntaxError: /home/projects/node-hyqpx9/code/exampleA.ts: /home/projects/node-hyqpx9/code/exampleA.ts: Invalid usage of `styled` tag
1 | import { styled } from '@linaria/react';
2 |
> 3 | export type StyledReturn = ReturnType<typeof styled>;
|
- Source in
./code/exampleA.ts
- To run
node ./testA.js
Reproducible Demo
https://stackblitz.com/edit/node-hyqpx9
Environment
@linaria/[email protected]Description
There are cases when a tag parser (or traversal) is too aggressive and causes unexpected failures. There are two cases that I currently found.
CJS re-export produced by TS
⬇️⬇️⬇️
Results in:
./code/exampleB.jsnode ./testB.jsUsage of identifier in TS types
Results in:
./code/exampleA.tsnode ./testA.jsReproducible Demo
https://stackblitz.com/edit/node-hyqpx9