question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[react native] Namespace not marked type-only declare.

See original GitHub issue

TensorFlow.js version

1.3.2

TensorFlow.js react-native version

0.1.0-alpha.2

Browser version

react-native 0.59.8 expo sdk 35.0.0 expo version 3.7.1

Describe the problem or feature request

Hi, I follow the steps in the page https://github.com/tensorflow/tfjs/tree/master/tfjs-react-native for a expo managed app, but I get the following error

node_modules/@tensorflow/tfjs-converter/dist/src/data/compiled_api.ts: 
/Users/itachi/my-apps/react/react-native/mobile-net/node_modules/@tensorflow/tfjs-converter/dist/src/data/compiled_api.ts: 
Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel. 
To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
  70 | }
  71 | 
> 72 | export namespace TensorShape {
     |                  ^^^^^^^^^^^
  73 |   /** Properties of a Dim. */
  74 |   export declare interface IDim {
  75 |     /** Dim size */
Failed building JavaScript bundle.

Code to reproduce the bug / link to feature request

These are the commands I’ve run

expo init mobile-net (-> Managed workflow)
cd mobile-net
expo install expo-gl
npm install @tensorflow/tfjs
npm install @tensorflow/tfjs-react-native@alpha
npm install @react-native-community/async-storage
npm install react-native-fs

Added the lines in the App.js file

import * as tf from '@tensorflow/tfjs';
import '@tensorflow/tfjs-react-native';

then

expo start

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

21reactions
ItachiUchiha91commented, Nov 23, 2019

Hi, I found the following solution. I installed the packages

npm install typescript react-native-typescript-transformer

Then I create, in the root of the project the file metro.config.js as

module.exports = {
    transformer: {
        babelTransformerPath: require.resolve(
            'react-native-typescript-transformer',
        ),
    },
};

And the file tsconfig.json as

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true
    }
}

At the moment I have no problem

10reactions
jeff3dxcommented, Mar 13, 2020

The error message is asking you to add “declare” to the namespace. You can defined your namespace like so: declare namespace MyNamespace {...} OR export declare namespace MyNamespace {...}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespace not marked type-only declare - Babel/Typescript
I used the packages react-app-rewired with the cutomize-cra. I created the config-overrides.js to overrides the config about cra (create-react- ...
Read more >
Namespace not marked type-only declare - Babel/Typescript ...
Mark type-only namespace s with declare . The regular allowNamespaces right into .babelrc would not work with create-react-app .
Read more >
Javascript – Namespace not marked type-only declare – Babel ...
I have created app via npx create-react-app –typescript. And I wanted to use some autogenerated code with namespaces due to that babel throw...
Read more >
babel/plugin-transform-typescript
It's not going away, but there are modern alternatives. Type-only namespace s should be marked with declare and will subsequently be safely removed....
Read more >
Documentation - TypeScript 3.8
Is only 'Foo' a type? Or every declaration in the import? // We just give an error because it's not clear. import type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found