【问题标题】:Declaring types in a non .ts file在非 .ts 文件中声明类型
【发布时间】:2019-11-12 04:41:45
【问题描述】:

我刚刚遇到一个 React-native 应用程序,它在 .js 文件中声明类型,如下所示:

this.notificationOpenedListener = firebase.notifications()
    .onNotificationOpened((notificationOpen: NotificationOpen) => {
        const notif: Notification = notificationOpen.notification;
        notificationOpenedClickHandler(notif)
});

我检查了 package.json 文件并且没有 typescript 包。 Vscode lint 将(notificationOpen: NotificationOpen) 部分下划线为红色。

这里发生了什么?

【问题讨论】:

  • 我不赞成这个问题收到的反对票。被包含针对其文件类型的无效语法的文件所混淆是完全合理的。

标签: javascript typescript flowtype google-closure-compiler


【解决方案1】:

我想代码使用flow 进行输入(在.js 文件中使用)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-11
    • 2011-08-25
    • 1970-01-01
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 2019-06-21
    相关资源
    最近更新 更多