How to warn when you forget to `await` an async function in Javascript?

The no-floating-promises ESLint rule requires you to explicitly handle any promises (e.g. with await or void). Here’s a minimal .eslintrc for use with TypeScript. Note that parserOptions is required for this rule: { “root”: true, “parser”: “@typescript-eslint/parser”, “parserOptions”: { “project”: “./tsconfig.json” }, “plugins”: [“@typescript-eslint”], “extends”: [“eslint:recommended”, “plugin:@typescript-eslint/recommended”], “rules”: { “@typescript-eslint/no-floating-promises”: [“error”] } } (ESLint is … Read more

Whats the difference between babel-preset-es2015 and babel-preset-env?

The babel-preset-es20XX (15, 16, 17) presets include transforms needed to convert features added in that specific year to code that is compatible with the previous version. babel-preset-env includes transforms for all features that have landed in the spec, but only enables the ones needed to make the features work based on the set of environments … Read more

What are the main differences between Babel and TypeScript

TypeScript is a superset of JavaScript that compiles down into plain JavaScript (ES3+). The main goal of TypeScript is to enable developers to leverage excellent static typing capabilities. It is suitable for large applications that would benefit from features like: Type annotations & type inference. Generics. Interfaces, enums, namespaces, modules and classes (the latter two … Read more

How do I configure absolute paths for imports in TypeScript based React Native apps?

Requirement // Meh import config from ‘../../../../../../../config’; // Awesome! import config from ‘@cuteapp/config’; How To Add this babel plugin package yarn add –dev babel-plugin-module-resolver My babel.config.js module.exports = { presets: [‘module:metro-react-native-babel-preset’], plugins: [ [ require.resolve(‘babel-plugin-module-resolver’), { cwd: ‘babelrc’, extensions: [‘.ts’, ‘.tsx’, ‘.js’, ‘.ios.js’, ‘.android.js’], alias: { ‘@cuteapp’: ‘./app’ } } ], ‘jest-hoist’ ] }; My … Read more

Babel throwing Support for the experimental syntax ‘jsx’ isn’t currently enabled

If this issue is related to using jest, jest config for your package.json should look like with typescript – “jest”: { … “transform”: { “^.+\\.(ts|tsx|js|jsx)$”: “ts-jest” }, … } with js – “jest”: { … “transform”: { “^.+\\.(js|jsx)$”: “babel-jest” }, … } If you have a jest.config.js then this goes in there: import type { … Read more

How to remove global “use strict” added by babel

As it has already been mentioned for Babel 6, it’s the transform-es2015-modules-commonjs preset which adds strict mode. In case you want to use the whole es2015 preset without module transformations, put this in your .babelrc file: { “presets”: [ [“es2015”, { “modules”: false }] ] } This will disable modules and strict mode, while keeping … Read more

Error using async/await in React Native

You might just be missing the async keyword on line 48. Update your code to use the async keyword before the function keyword: renderScene: async function(route, nav) { try { const response = await signIn.isLoggedIn(); // … Or when using an arrow function, put the async keyword before the parameter list: renderScene: async (route, nav) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)