Getting a TypeScript error in Declaration or statement expected. TS1128 - react-mui

trying to use the dialog sample progect and I am getting the following error: #mui/base/FormControlUnstyled/index.d.ts(3,1):
Declaration or statement expected. TS1128
1 | export { default } from './FormControlUnstyled';
2 | export { default as FormControlUnstyledContext } from './FormControlUnstyledContext';
3 | export type { FormControlUnstyledProps, FormControlUnstyledComponentsPropsOverrides, FormControlUnstyledState, } from './FormControlUnstyled.types';
| ^
I am expecting the dialog sample to work

Related

Parcel and react 18 project set up error. #parcel/transformer-js: Unexpected token `)`. Expected this, import, async, function

Server running at http://localhost:1234
🚨 Build failed.
#parcel/transformer-js: Unexpected token ). Expected this, import, async, function, [ for array literal, { for object literal, # for
decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
/home/sizzions/Desktop/Projects/web app/WenApp/src/index.js:5:19
4 | const root = createRoot(container); // createRoot(container!) if you use TypeScript
5 | root.render(/);
| ^
`import { createRoot } from 'react-dom/client';
import App from './App';
const container = document.getElementById('app');
const root = createRoot(container); // createRoot(container!) if you use TypeScript
root.render(<App/>);`
FWIW, I ran into this for a few minutes until I realized react wasn't no longer in my package.json file. After adding react 18 back in I was good to move on to my next error. :)

Protractor - Cucumber not picking values from Examples

Protractor - Cucumber not picking values from Examples. I am using site "http://juliemr.github.io/protractor-demo/" in first text box it enters <key1> and <key2>.
Feature file is below
Feature: Navigate to calculator site and add two number
Scenario: Add two number using calculator site
Given Navigate to calculator site url "http://juliemr.github.io/protractor-demo/"
When Provide two numbers to add first number "< key1 >" and "< key2 >"
Then Click on add button on calculator site
Scenario Outline: Provide parameters
Examples:
| key1 | key2 |
| 2 | 3 |
| 2 | 60 |
Step definition file
import { Given, When, Then } from "cucumber";
import { browser } from "protractor";
import { calculator } from "../pageObjects/calculator";
let cal = new calculator();
Given('Navigate to calculator site url {string}', async (string)=> {
// Write code here that turns the phrase above into concrete actions
await browser.get(string);
});
When('Provide two numbers to add first number {string} and {string}', async (firstValue:string,
secondvalue:string)=> {
// Write code here that turns the phrase above into concrete actions
await cal.firstEditBox.sendKeys(firstValue);
await cal.secondEditBox.sendKeys(secondvalue);
});
Then('Click on add button on calculator site', async ()=> {
// Write code here that turns the phrase above into concrete actions
await cal.goButton.click;
cal.getResult.getText().then(function(text) {
console.log(text);
})
});
Error
Feature file
Feature: To search keywords in google
#OutlineScenario
Scenario Outline: Searching on google
Given I am on "<search>" search page
When I type "<search keyword>"
Then I click on search button
Then I clear the search text
Examples:
| search | search keyword |
| google | cucumber |
| cucumber | protractor |
| protractor | typescript |
Step def
Given(/^I am on "(.*?)" search page$/, async (text) => {
if (text === "google") {
await expect(browser.getTitle()).to.eventually.equal("Google");
} else if (text === "cucumber") {
await expect(browser.getTitle()).to.eventually.equal(text + " - Google Search");
} else if (text === "protractor") {
await expect(browser.getTitle()).to.eventually.equal(text + " - Google Search");
}
});
When(/^I type "(.*?)"$/, async (text) => {
await search.searchTextBox.sendKeys(text);
});
Please mention "Scenario Outline:" instead of "Scenario:" in the first line of your Feature file. Then it will be resolved. Otherwise everything is alright in your code. It should be like below:
Scenario Outline: Add two number using calculator site
"Scenario Outline: Provide parameters"- Please remove this line from your feature file.

Babel: replaceWithSourceString giving Unexpected token (1:1)

I am trying to replace dynamically "import" statements.
Here is an example that checks if the import ends with a Plus.
module.exports = function(babel) {
return {
visitor: {
ImportDeclaration: function(path, state) {
// import abc from "./logic/+"
if( ! path.node.source.value.endsWith("/+"))
return;
path.replaceWithSourceString('import all from "./logic/all"')
}
}
}
}
This gives an error of
SyntaxError: src/boom.js: Unexpected token (1:1) - make sure this is an expression.
> 1 | (import all from "./logic/all")
The problem is that replaceWithSourceString is wrapping the string in rounded braces.
If I change the replaceWithSourceString to
path.replaceWithSourceString('console.log("Hi")')
and this works.. ¯_(ツ)_/¯
Any and all help you be great
replaceWithSourceString should really be avoided, because it is just not a very good API, as you are seeing. The recommended approach for creating ASTs to insert into the script is to use template. Assuming this is for Babel 7.x, you can do
const importNode = babel.template.statement.ast`import all from "./logic/all"`;
path.replaceWith(importNode);

Infinite recursion in Rust derive macro?

I have made the following attampt at a derive macro in Rust:
extern crate proc_macro;
use crate::proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(DeserializeConfigurable)]
pub fn deserialize_configurable_derive(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let name = &ast.ident;
let gen = quote! {
impl<'de> Deserialize<'de> for #name {
fn deserialize<D>(deserializer: D) -> Result<#name, D::Error>
where
D: Deserializer<'de>,
{
let config = <#name as Configurable>::Config::deserialize(deserializer)?;
Ok(#name::from_config(config))
}
}
};
gen.into()
}
The goal is to provide a specific blanket implementation for deserialize based on another trait, Configurable.
However, the compiler has the following complaint regarding my quote statement:
recursion limit reached while expanding the macro stringify
I don't see the recursion here. I am not even using stringify! What is calling what in infinity here?
Trying to compile this locally gives this full error message:
error: recursion limit reached while expanding the macro `stringify`
--> src/lib.rs:13:15
|
13 | let gen = quote! {
| _______________^
14 | | impl<'de> Deserialize<'de> for #name {
15 | | fn deserialize<D>(deserializer: D) -> Result<#name, D::Error>
16 | | where
... |
22 | | }
23 | | };
| |_____^
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
Putting the following as the first line of the crate makes the error go away. My guess is that the default recursion_limit is simply too low for a macro this complex (which IMO isn't that complex). I'm sure there's a good reason, and I'm glad the error message contained the solution:
#![recursion_limit="128"]

Switching between lexical states in javaCC

I am trying to create a javaCC parser that will behave differently in two code blocks for custom NetBeans plugin, however I cant even recognize two states. I don't know what I am doing wrong.
<DEFAULT,STATE1>
SKIP : {
" "
| "\t"
| "\n"
| "\r"
}
TOKEN : {
< A1: "a"> : STATE1
}
< STATE1 > TOKEN : {
< B2: "b" > : DEFAULT
}
This simple parser does not parse string "abab..".
There is no rule for "."; so, after parsing "abab", the lexer is stuck. This is why the error message says 'Lexical error at line 1, column 5. Encountered: "." (46), after : ""' If you add
| "."
to the first rule, it will work.