Skip to content

Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. #377

Closed
@andys8

Description

@andys8

Describe the bug
I'm trying to get started with js-lingui.

/src/locales/de/messages.js
Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided.  TS1208

  > 1 | /* eslint-disable */module.exports={languageData:{"plurals":function(n,ord){var s=String(n).split("."),v0=!s[1];if(ord)return"other";return n==1&&v0?"one":"other"}},messages:{"description":"Beschreibung"}};
      |                     ^

To Reproduce
Steps to reproduce the behavior, possibly with minimal code sample, e.g:

import * as React from 'react';
import { I18nProvider } from '@lingui/react';
import { Header } from './Header';

import catalogDe from '../locales/de/messages.js';
import catalogEn from '../locales/en/messages.js';

const catalogs = {
  de: catalogDe,
  en: catalogEn,
};

export const App = () => (
  <I18nProvider language="en" catalogs={catalogs}>
      <Header /> 
  </I18nProvider>
);

export default App;

Expected behavior
Should compile

Additional context
Using create-react-app, newest version where they introduces typescript support

{
    "@babel/core": "7.1.2",
    "@lingui/react": "2.7.0",
    "@lingui/cli": "2.7.0",
    "@lingui/macro": "2.7.0",
    "@types/lingui__core": "2.1.1",
    "@types/lingui__macro": "2.7.0",
    "@types/lingui__react": "2.5.0",
    "babel-core": "7.0.0-bridge.0",
    "react-scripts": "2.1.0",
    "typescript": "3.1.4"
}

tsconfig.json

create-react-app needs isolatedModules set to true.

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es6", "dom"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "importHelpers": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ],
  "include": ["src"]
}

This issue could be related, although it is about json: microsoft/TypeScript#28207

I guess I've a mistake in usage or configuration or it's a beginner mistake. I appreciate the help. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions