The following code is generated in bundle.js.
Internet Explorer states there's a syntax error for class and that is correct.
Why is this in my bundle.js and how can I fix this?
let Screen = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mobx_react__["observer"])
(_class = class Screen extends __WEBPACK_IMPORTED_MODULE_0_react__["Component"] {
componentDidMount() {
if (this.componentWillRender) {
this.componentWillRender(this.props);
}
}
}) || _class;
SCRIPT0001: Syntax error
bundle.js (12470,99)
Related
When debugging typescript code from my testcases in Intellij Idea I get the following error inside the Evaluate window (Alt + F8):
ReferenceError: InternalServerException is not defined
at eval (eval at getStatusCodeAndResponse (C:\Users\<user>\Documents\Projecten\stations-api\app\common\error-handler.ts:17:13), <anonymous>:1:1)
at Object.getStatusCodeAndResponse (C:\Users\<user>\Documents\Projecten\stations-api\app\common\error-handler.ts:17:13)
at Lambda.handler (C:\Users\<user>\Documents\Projecten\stations-api\app\get-guiding-lines-combinations.ts:38:20)
at Lambda.<anonymous> (C:\Users\<user>\Documents\Projecten\stations-api\node_modules\#aws-lambda-powertools\metrics\src\Metrics.ts:277:41)
at Lambda.<anonymous> (C:\Users\<user>\Documents\Projecten\stations-api\node_modules\#aws-lambda-powertools\logger\src\Logger.ts:337:41)
at Lambda.<anonymous> (C:\Users\<user>\Documents\Projecten\stations-api\node_modules\#aws-lambda-powertools\tracer\src\Tracer.ts:364:33)
at Object.<anonymous> (C:\Users\<user>\Documents\Projecten\stations-api\app\get-guiding-lines-combinations.test.ts:41:41)
at Promise.then.completed (C:\Users\<user>\Documents\Projecten\stations-api\node_modules\jest-circus\build\utils.js:391:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (C:\Users\<user>\Documents\Projecten\stations-api\node_modules\jest-circus\build\utils.js:316:10)
The way I import my custom class:
import {
BadRequestException,
Exception,
InternalServerException,
NotFoundException,
} from '../models/Exceptions';
The custom class itself:
export class InternalServerException implements Error {
message: string;
name: string = 'InternalServer';
statusCode: number = 500;
constructor(message?: string) {
this.message = message ?? 'Internal server exception';
}
createResponse(): APIGatewayProxyStructuredResultV2 {
return {
statusCode: this.statusCode,
body: this.message,
};
}
}
While it can easely find my custom classes etc when running the tests. How can I get my classes recognized inside the evaluate window? Since this makes debugging a lot easier. (The version I am using is Intellij Idea 2022.3.2 ultimate)
I want to open the details settings of my application from the app itself.
I use the IntentLauncher from Expo itself: https://docs.expo.io/versions/latest/sdk/intent-launcher
The code I use that I assume should work is:
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_DETAILS_SETTINGS)
But this gives me this error:
[Unhandled promise rejection: Error: Encountered an exception while calling native method: Exception occurred while executing exported method startActivity on module ExpoIntentLauncher: null]
I'm not sure if I should give some kind of parameter with it so it links to my app?
Opening all other settings does work, ex:
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS)
This does open a list off all apps, I just need to get the detailed screen of the app itself, not the list.
I found this solution by bodolsog working.
Complete solution
import * as IntentLauncher from "expo-intent-launcher";
import Constants from "expo-constants";
const pkg = Constants.manifest.releaseChannel
? Constants.manifest.android.package // When published, considered as using standalone build
: "host.exp.exponent"; // In expo client mode
IntentLauncherAndroid.startActivityAsync(
IntentLauncherAndroid.ACTION_APPLICATION_DETAILS_SETTINGS,
{ data: 'package:' + pkg },
)
Hope this helps someone
import { startActivityAsync, ActivityAction } from 'expo-intent-launcher';
import * as Linking from 'expo-linking';
import Constants from 'expo-constants';
const pkg = Constants.manifest.releaseChannel
? Constants.manifest.android.package // When published, considered as using standalone build
: 'host.exp.exponent'; // In expo client mode
openSettings = async () => {
try {
if (Platform.OS === 'android') {
// console.log(Constants);
startActivityAsync(ActivityAction.APPLICATION_DETAILS_SETTINGS, {
data: 'package:' + pkg,
});
}
if (Platform.OS === 'ios') {
Linking.openSettings();
}
} catch (error) {
console.log(error);
}
};
I have two modules in one folder, mod1.js:
'use strict';
export class MyClass {
constructor() {
}
lala() {
alert(1);
}
}
And mod2.js:
'use strict';
import {MyClass} from './mod1';
let c = new MyClass();
c.lala2(); //HERE I WANT TO SEE ERROR
The problem is that Visual Studio Code doesn't show error in mod2. How to make it show the error, if it is possible?
I have a Typescript project, which calls a function from a module.js module. Here is my initial code:
//app.ts
import { MobileServiceUser, setCache, getCache } from "nativescript-azure-mobile-apps/user";
export function onLoginTap(args) {
console.log("tap");
ai.busy = true;
var cache = getCache();
}
if I use the VSCode "go to definition" feature, then getCache() goes to the import statement at the top, if I do this again, then I go to:
//module.ts
declare module "nativescript-azure-mobile-apps/user" {
export class MobileServiceUser {
mAuthenticationToken: string;
mUserId: string;
constructor(o: { userId: string; });
}
export function setCache(user: MobileServiceUser): void;
export function getCache(): MobileServiceUser;
}
When I execute the code and the var cache = user_1.getCache(); line is executed, my app crashes, throwing error:
TypeError: user_1.getCache is not a function
File: "/data/data/inc.tangra.azuremobileservicessample/files/app/main-page.js, line: 94, column: 23
app.ts looks like this compiled to js:
var user_1 = require("nativescript-azure-mobile-apps/user");
function onLoginTap(args) {
console.log("tap");
ai.busy = true;
var cache = user_1.getCache();
}
Why isn't the code recognising the imported function?
Update: this repo shows the project structure (the first page of code is in sample/main-page.ts
///<reference path="HtmlElementsAction.ts" />
///<reference path="DesktopSocket.ts" />
module Pong {
export class webPage extends HtmlElementsAction {
private socket;
constructor() {
super();
this.socket = new DesktopSocket(this);
}
}
}
I've this code.
When I'm executing it, in browser's console is error:
Uncaught TypeError: undefined is not a function
Error is on new DesktopSocket(this);
What am I doing wrong?
Common error. Check the order of your script tags or if compiling with "out" the order of arguments to tsc.