How can I translate this.js file into a Typescript one?
import * as Colors from './colors';
import * as Spacing from './spacing';
import * as Typography from './typography';
import * as Mixins from './mixins';
export { Typography, Spacing, Colors, Mixins };
Thank you
Edit 1: I'm trying to fix the folowing error:
Cannot find module '_styles' or its corresponding type declarations.
When trying to import a file in another file
import {Colors,Typography,Mixins} from '_styles';
It works, but shows the above warning. I have a setup that allow my to import the file without the complete path that works well but with typescript, it shows a warning.
Edit 2:
I have the following setup in.babelrc
{
"plugins": [
[
"module-resolver",
{
"cwd": "babelrc",
"root": ["./src"],
"extensions": [".js", ".ios.js", ".android.js", ".ts", ".tsx", ".json"],
"alias": {
"_assets": "./src/assets",
"_components": "./src/components",
"_atoms": "./src/components/atoms",
"_molecules": "./src/components/molecules",
"_organisms": "./src/components/organisms",
"_navigations": "./src/navigations",
"_scenes": "./src/scenes",
"_services": "./src/services",
"_styles": "./src/styles",
"_utils": "./src/utils",
"_i18n": "./src/i18n"
}
}
]
]
}
From TS 3.8 the new syntax is introduces export * as ns from '...'
How about use this?
export * as Colors from './colors';
export * as Spacing from './spacing';
export * as Typography from './typography';
export * as Mixins from './mixins';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.