我有以下打字稿文件:
let constants = {
urls: {
delegates: {
AUTHENTICATION: {
LOGIN: "auth/pub/login", // User Login (POST)
LOGOUT: "auth/pub/logout", // User Logout
PASSWORD_CHANGE: "security/pub/changepassword", // Change user password (POST)
PASSWORD_RESET: "security/pub/resetpassword", // Reset user password (POST)
PASSWORD_FORGOT: "security/pub/forgotpassword/{email}" // Forgot password
},
...
export constants.urls;//Does not compile...
我收到以下错误消息:
Expected function, variable, class, interface or namespace declaration.
Expression statement is not an assignment or call.
修改:我试过了:
const urls = constants.urls;
export urls;
并导致相同的错误消息...
编辑2 :感谢下面的回复和Matt的评论,我提出了这个工作正常:
const URLS = constants.urls;
export {URLS};
答案 0 :(得分:1)
Use
let constants = {
urls: {
delegates: {
AUTHENTICATION: {
LOGIN: "auth/pub/login", // User Login (POST)
LOGOUT: "auth/pub/logout", // User Logout
PASSWORD_CHANGE: "security/pub/changepassword", // Change user password (POST)
PASSWORD_RESET: "security/pub/resetpassword", // Reset user password (POST)
PASSWORD_FORGOT: "security/pub/forgotpassword/{email}" // Forgot password
},
...
const urls = constants.urls
export {urls};