-
Notifications
You must be signed in to change notification settings - Fork 131
Type error: 'from' expected - 2.35.8 #399
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, just open the index at -> node_modules/three-stdlib/index.d.ts and fix all the pathing back to normal import format aka (export type * from './environments/RoomEnvironment.d.ts') - then you will need to create a patch with patch-package ( |
I ran into this as well. It appears to be related to https://github.com/pmndrs/three-stdlib/releases/tag/v2.35.8, and more specifically, the introduction of this patch file: 8e15117#diff-93d353a7a92f421b8eb2cdb883d8c75f31a4ba25d28503ada3a7e5a4e2b5dc0f Apologies for blasting a block of code below, but I wrote a quick test script to do a sanity-check on the regexes in the above changes. Perhaps it will aid in further validation. (Side note: I highly advise you read the code before blindly running it; there's no reason to trust some random dude's script, and I'm a random dude.) I excluded The test output should demonstrate that the above change is now creating invalid syntax. const fs = require("node:fs");
// Test file
const testFile = "./test.ts";
// Write a minimal test containing valid module code
fs.writeFileSync(
testFile,
`
export * from './module';
export { something } from './module.js';
import { AnotherThing } from './another-module';
declare module './module';
`,
);
// Mimic shelljs `sed` so we have a self-contained test script
function sed(searchRegex, replaceValue, file) {
const content = fs.readFileSync(file, "utf-8");
const updatedContent = content.replace(searchRegex, replaceValue);
fs.writeFileSync(file, updatedContent, "utf-8");
}
// Start regex validation from release https://github.com/pmndrs/three-stdlib/releases/tag/v2.35.8
// Add type qualifiers in annotations
sed(/(import|export [*{])\s+(?!type\b)/, "$1 type ", testFile);
// NOTE: if you'd like to test a *potential* fix, comment out the line above and uncomment the line below
// sed(/(import|export {)\s+(?!type\b)/, "$1 type ", testFile);
// Remove .js extensions
sed(/from '(\.[^.]+)\.js'/, "from '$1'", testFile);
// Add explicit .d.ts extensions for ESM
sed(/ from '(\.[^']+)'/, " from '$1.d.ts'", testFile);
sed(/^declare module '(\.[^']+)'/, "declare module '$1.d.ts'", testFile);
// End regex validation
// Log the result
const result = fs.readFileSync(testFile, "utf-8");
console.log("Transformed test.ts:\n", result); I'm not up to speed on the broader context and objectives around the change that introduced this issue, otherwise I'd open a PR. I know a lot of people rely on the stability of this library, and I don't want to increase the blast radius by making a naive change. Hopefully this is helpful. I appreciate all the hard work that goes into this library. In the immediate term, I chose to roll back my |
The same happens to me but in I used |
try previous package npm i three-stdlib@2.35.7 i am not sure with three version but try this |
@CodyJasonBennett this is related to issue #342 and the fix in #343. |
I'm taking a shot at the PR, if I can get the regex right... |
PR available #400 |
🎉 This issue has been resolved in version 2.35.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
three@0.171.0
three-stdlib@2.35.8
@react-spring/three@9.7.5
@react-three/drei@9.121.2
@react-three/fiber@9.0.0-rc.4
Problem description:
Building (npm run build) causes the below issue now (as a few hours ago -> 2.35.8)
./node_modules/three-stdlib/index.d.ts:1:10
Type error: 'from' expected.
Suggested solution:
I had to patch this back to -> export type * from './misc/xxxx.d.ts';
as "export * type from './misc/xxxx.d.ts';" is not valud exporting format.
The text was updated successfully, but these errors were encountered: