Identifier expected.ts(1003) with Alpinejs and Astro - visual-studio-code

I'm using Aplinejs (3.11.1) with Astro.build (2.0.13) and have the following on a div
x-on:click.outside="shownav = false"
I'm getting the following error in VS Code (1.74.3) on the "."
Identifier expected.ts(1003)
I'm new to VS Code, Alpine and Astro, so I'm not sure how to get rid of this error. Can someone advise? I'm using TypeScript 4.9.5.
Separate but related, for anyone getting the following error on "outside":
Property 'outside' does not exist on type 'HTMLAttributes'.ts(2322)
I sorted that by adding this to src/custom-attributes.d.ts
declare namespace astroHTML.JSX {
interface HTMLAttributes {
outside?: string;
}}

Version of the Astro VS Code extension lower than 0.29.0 don't support Alpine correctly. (See this issue)
At the time of writing, 0.29.0 is only available in Pre-release. You can update to it by pressing the Switch to Pre-Release button on the extension page.
Screenshot of the extension page

Related

How to replace deprecated SOBE Code in TYPO3 10.4

I inherited an old TYPO3 Extension using SOBE. As far as I unterstand it's deprecated, but it seems there is no documentation on how to replace it.
The Extension is using Backend Forms and the following line is throwing an error:
if (is_array($GLOBALS['SOBE']->editconf['tt_content']) && reset($GLOBALS['SOBE']->editconf['tt_content']) === 'new') {
The error is:
Cannot access protected property TYPO3\CMS\Backend\Controller\EditDocumentController::$editconf
The Var $GLOBALS['SOBE'] is still there, and there is also editconf, but it's not working.
How can I replace this code or rewrite it?
The SOBE object is part by part removed since years. As there are multiple ways for using it - see https://docs.typo3.org/c/typo3/cms-core/main/en-us/search.html?q=sobe&check_keywords=yes&area=default - you may need to take a closer look what is the exact part of replacing this code.
I would guess you can see more at https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.2/Deprecation-84195-ProtectedMethodsAndPropertiesInEditDocumentController.html?highlight=editconf.

How to read html files on Vapor with Leaf when not using the tau version?

There was a version of Leaf that I was using to load .html files instead of .leaf ones from my Vapor project, which would make syntax coloring for those same files done automatically.
The version of Leaf was 4.0.0-tau.1 and the one for LeafKit was 1.0.0-tau.1.1
When using this particular version, I could setup leaf in the configure.swift file this way:
/// Change the classic .leaf extension to .html for the syntax
/// coloring option of Xcode to work each time the app is being load up.
fileprivate func leaf(_ app: Application) {
if !app.environment.isRelease {
LeafRenderer.Option.caching = .bypass // Another issue from the update
}
let detected = LeafEngine.rootDirectory ?? app.directory.viewsDirectory
LeafEngine.rootDirectory = detected
LeafEngine.sources = .singleSource(
NIOLeafFiles(fileio: app.fileio,
limits: .default,
sandboxDirectory: detected,
viewDirectory: detected,
defaultExtension: "html"))
app.views.use(.leaf)
}
In this code, the LeafRenderer.Option.caching = .bypass and the code used with LeafEngine do not work anymore since having updated Leaf to 4.1.3 and LeafKit to 1.3.1.
How can I successfully make this code work as before with the updated Leaf and LeafKit frameworks?
You can use this Xcode plugin:
https://github.com/OmranK/VaporLeafPlugIn
It adds Vapor Leaf language support to Xcode IDE. Provides syntax highlighting for Leaf tags as well as HTML tags with auto-indentation all together.
At the moment the plugin supports Xcode up to 13.2 beta. Future Xcode versions will require small update (add new DVTPlugInCompatibilityUUID) but it can be easily handled even on already installed plugin.

How to turn off VS Code Error "Property does not exist on type {}" (ts) on .JS files

I am editing React JS files, not TS. The latest VS Code marks some tokens with an ellipsis (...) and displays the following:
This did not happen before, it started with the latest upgrade of VS Code. How to turn it off?
You can use casting to inforce typing for example:
interface IUser{
firstName: string
lastName:string
}
const hi = {} as IUser
hi.firstName // ok

How to get DPI device to PCL in Xamarin. Forms? - Followup

Using Xamarin Forms Visual Studio 2019.
I need to get the DPI of the device.
This post has a solution:
How to get DPI device to PCL in Xamarin. Forms?
Implementing the solution gave problems:
When applying the answer above I get this error message:
The type or namespace name 'DependencyAttribute' could not be found
(are you missing a using directive or an assembly reference?)
In your android implementation, add a new class:
[assembly: Dependency(typeof(DisplayInfo))]
namespace .....
--I solved this compiler problem by replacing with:
using Xamarin.Essentials;
[assembly: Xamarin.Forms.Dependency(typeof(DisplayInfo))]
However when I compile and run the code, it falls over when I try consume this in the Xamarin Core Code:
int dpi = DependencyService.Get<IDisplayInfo>().GetDisplayDpi();
I get this runtime error on the above line:
System.NullReferenceException: Object reference not set to an instance
of an object
Any ideas? I would have added this question as a comment on the original, but as a new user do not have the points to do this... If someone could drop a comment on the original question's solution pointing it to this URL that would be helpful too.
So the answer to my own question:
The solution original offered said do this:
In your android implementation, add a new class:
[assembly: Dependency(typeof(DisplayInfo))]
namespace YourAppNamespace.Droid
{
public class DisplayInfo : IDisplayInfo
{
public int GetDisplayWidth()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.WidthPixels;
}
public int GetDisplayHeight()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.HeightPixels;
}
public int GetDisplayDpi()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.DensityDpi;
}
}
}
The problem I did not see anywhere in the Android code that initialised this class, and I was unsure how best to do this really.
So I followed guidance for implementing the interface directly in the Android MainActivity.cs file, and this worked.. The video I watched to help me on that is here:
https://www.youtube.com/watch?v=lgcnYDb6cRQ&t=19s

what could I be missing in my typo3 extension to cause a table does not exist error?

I am getting this error after adding to an extension a class from another extension:
Uncaught TYPO3 Exception
#1247602160: Table 'deva.tx_bingoprizes_domain_model_hall' doesn't exist: SELECT tx_bingoprizes_domain_model_hall.* FROM tx_bingoprizes_domain_model_hall WHERE tx_bingoprizes_domain_model_hall.uid IN ('0') LIMIT 1
Tx_Extbase_Persistence_Storage_Exception_SqlError thrown in file
/home/typo3_src/typo3_src-4.5.32/typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php in line 1008.
The class added is tx_bingoprizes_domain_model_hall which should be reading from the table tx_bpscore_domain_model_hall as I added to the setup file:
config.tx_extbase.persistence.classes {
Tx_Bingoprizes_Domain_Model_Hall {
mapping {
tableName = tx_bpscore_domain_model_hall
}
}
}
as I did for other extension which also reuses this class and which works properly ( I use it as my model for how to do this and as near as I can tell did everything the same way ). Why is typo3 still trying to use table tx_bingoprizes_domain_model_hall? where else do I need to specify the other table? I tried restarting the server, clearing caches, reinstalling the extension but still get the error.
I am using the latest 4.5 typo3.
Thanks
to reiterate my comment as the answer...
OK, I got it. Once again I had forgotten to INCLUDE the necessary item (in this case bingoprizes) to the page's template. So the error was not in my extension but in the typo3 config for the page. I hate that, forget it all the time, it is counter-intuitive to me as I find it natural to assume the setup.txt stuff is auto included on any page that uses my extension.