-
Notifications
You must be signed in to change notification settings - Fork 415
Closed
Labels
bug report 🦗Issue is probably a bug, but it needs to be checkedIssue is probably a bug, but it needs to be checkedneeds: complete repro 🖥️Issue need to have complete repro providedIssue need to have complete repro provided
Description
Environment
- Linaria version:
@linaria/babel-preset@4.4.2 - 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug report 🦗Issue is probably a bug, but it needs to be checkedIssue is probably a bug, but it needs to be checkedneeds: complete repro 🖥️Issue need to have complete repro providedIssue need to have complete repro provided