typescript - 无法分配给 'd',因为它不是变量 typescript

标签 typescript variables import interface

您好,我有两个文件使用相同的接口(interface)和变量,所以我试图将变量导入另一个 typescript 文件。该接口(interface)也是从全局接口(interface)文件导入的。

declare interface personInterface {
    name: string;
    surname: string;
}

export let d: personInterface = {
    name: '',
    surname: ''
};

我正在导入然后 d 到另一个文件中:

import { d } from "./file";

d = sessionStorage.getItem("person");

我收到以下错误: 无法分配给“d”,因为它不是变量。

最佳答案

import {d} from ... 就像

const d = ...;

这就是为什么你不能重新分配常量

关于typescript - 无法分配给 'd',因为它不是变量 typescript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60262211/

相关文章:

python - 在 Tkinter 中导入图像作为背景

javascript - 使用 Typescript/javascript 自定义排序

javascript - Angular 5 - 在 Angular 应用程序中使用 altmetric 徽章会出现 Uncaught Error : Template parse errors

typescript - 具有函数参数的对象的索引签名

c - 在C语言中,如何在单独的变量中使用多个字符串

在 IntelliJ IDEA : cannot resolve symbol 'google' but project compiles 中使用 Gradle 的 Java 项目

python - 在python中导入和使用模块

angular - 属性 'loaded' 在类型 'HttpSentEvent' 上不存在

c# - C# 命令提示的新手并试图理解此代码

java - 函数内的多线程变量访问